appjam 0.1.0.pre4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE.txt +20 -0
- data/README.rdoc +27 -0
- data/bin/appjam +17 -0
- data/lib/appjam.rb +50 -0
- data/lib/appjam/generators/Classes/ContactsAppDelegate.h.tt +18 -0
- data/lib/appjam/generators/Classes/ContactsAppDelegate.m.tt +88 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/core/Controller.h +54 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/core/Controller.m +145 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/core/Model.h +47 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/core/Model.m +117 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/core/View.h +39 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/core/View.m +207 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/interfaces/ICommand.h +16 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/interfaces/IController.h +57 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/interfaces/IFacade.h +135 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/interfaces/IMediator.h +84 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/interfaces/IModel.h +50 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/interfaces/INotification.h +57 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/interfaces/INotifier.h +41 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/interfaces/IObserver.h +67 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/interfaces/IProxy.h +53 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/interfaces/IView.h +96 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/command/MacroCommand.h +50 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/command/MacroCommand.m +101 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/command/SimpleCommand.h +28 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/command/SimpleCommand.m +34 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/facade/Facade.h +52 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/facade/Facade.m +304 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/mediator/Mediator.h +35 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/mediator/Mediator.m +101 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/observer/Notification.h +52 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/observer/Notification.m +71 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/observer/Notifier.h +40 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/observer/Notifier.m +54 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/observer/Observer.h +42 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/observer/Observer.m +67 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/proxy/Proxy.h +51 -0
- data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/proxy/Proxy.m +73 -0
- data/lib/appjam/generators/Classes/users/ApplicationFacade.h.tt +31 -0
- data/lib/appjam/generators/Classes/users/ApplicationFacade.m.tt +33 -0
- data/lib/appjam/generators/Classes/users/controller/CreateUserCommand.h.tt +16 -0
- data/lib/appjam/generators/Classes/users/controller/CreateUserCommand.m.tt +27 -0
- data/lib/appjam/generators/Classes/users/controller/DeleteUserCommand.h.tt +16 -0
- data/lib/appjam/generators/Classes/users/controller/DeleteUserCommand.m.tt +21 -0
- data/lib/appjam/generators/Classes/users/controller/GetUsersCommand.h.tt +17 -0
- data/lib/appjam/generators/Classes/users/controller/GetUsersCommand.m.tt +21 -0
- data/lib/appjam/generators/Classes/users/controller/StartupCommand.h.tt +16 -0
- data/lib/appjam/generators/Classes/users/controller/StartupCommand.m.tt +29 -0
- data/lib/appjam/generators/Classes/users/controller/UpdateUserCommand.h.tt +16 -0
- data/lib/appjam/generators/Classes/users/controller/UpdateUserCommand.m.tt +27 -0
- data/lib/appjam/generators/Classes/users/model/UserProxy.h.tt +19 -0
- data/lib/appjam/generators/Classes/users/model/UserProxy.m.tt +59 -0
- data/lib/appjam/generators/Classes/users/model/vo/UserVO.h.tt +22 -0
- data/lib/appjam/generators/Classes/users/model/vo/UserVO.m.tt +47 -0
- data/lib/appjam/generators/Classes/users/view/ContactsMediator.h.tt +15 -0
- data/lib/appjam/generators/Classes/users/view/ContactsMediator.m.tt +43 -0
- data/lib/appjam/generators/Classes/users/view/UserFormMediator.h.tt +17 -0
- data/lib/appjam/generators/Classes/users/view/UserFormMediator.m.tt +57 -0
- data/lib/appjam/generators/Classes/users/view/UserListMediator.h.tt +17 -0
- data/lib/appjam/generators/Classes/users/view/UserListMediator.m.tt +59 -0
- data/lib/appjam/generators/Classes/users/view/components/Contacts.h.tt +27 -0
- data/lib/appjam/generators/Classes/users/view/components/Contacts.m.tt +46 -0
- data/lib/appjam/generators/Classes/users/view/components/UserForm.h.tt +37 -0
- data/lib/appjam/generators/Classes/users/view/components/UserForm.m.tt +118 -0
- data/lib/appjam/generators/Classes/users/view/components/UserList.h.tt +31 -0
- data/lib/appjam/generators/Classes/users/view/components/UserList.m.tt +77 -0
- data/lib/appjam/generators/Contacts-Info.plist.tt +28 -0
- data/lib/appjam/generators/Contacts.xcodeproj/eiffel.pbxuser +1671 -0
- data/lib/appjam/generators/Contacts.xcodeproj/eiffel.perspectivev3 +1638 -0
- data/lib/appjam/generators/Contacts.xcodeproj/project.pbxproj +574 -0
- data/lib/appjam/generators/Contacts_Prefix.pch.tt +8 -0
- data/lib/appjam/generators/app.rb +78 -0
- data/lib/appjam/generators/main.m.tt +17 -0
- data/lib/appjam/generators/utils/NSStringWhiteSpace.h +17 -0
- data/lib/appjam/generators/utils/NSStringWhiteSpace.m +31 -0
- data/lib/appjam/generators/utils/UIDevice.h +17 -0
- data/lib/appjam/generators/utils/UIDevice.m +83 -0
- data/lib/appjam/generators/utils/URLEncodeString.h +16 -0
- data/lib/appjam/generators/utils/URLEncodeString.m +29 -0
- data/lib/appjam/version.rb +10 -0
- data/spec/appjam_spec.rb +7 -0
- data/spec/spec_helper.rb +12 -0
- metadata +270 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#import "INotification.h"
|
|
2
|
+
/**
|
|
3
|
+
* The interface definition for a PureMVC Mediator.
|
|
4
|
+
*
|
|
5
|
+
* <P>
|
|
6
|
+
* In PureMVC, <code>IMediator</code> implementors assume these responsibilities:</P>
|
|
7
|
+
* <UL>
|
|
8
|
+
* <LI>Implement a common method which returns a list of all <code>INotification</code>s
|
|
9
|
+
* the <code>IMediator</code> has interest in.</LI>
|
|
10
|
+
* <LI>Implement a notification callback method.</LI>
|
|
11
|
+
* <LI>Implement methods that are called when the IMediator is registered or removed from the View.</LI>
|
|
12
|
+
* </UL>
|
|
13
|
+
* <P>
|
|
14
|
+
* Additionally, <code>IMediator</code>s typically:
|
|
15
|
+
* <UL>
|
|
16
|
+
* <LI>Act as an intermediary between one or more view components such as text boxes or
|
|
17
|
+
* list controls, maintaining references and coordinating their behavior.</LI>
|
|
18
|
+
* <LI>Respond to and generate <code>INotifications</code>, interacting with of
|
|
19
|
+
* the rest of the PureMVC app.
|
|
20
|
+
* </UL></P>
|
|
21
|
+
* <P>
|
|
22
|
+
* When an <code>IMediator</code> is registered with the <code>IView</code>,
|
|
23
|
+
* the <code>IView</code> will call the <code>IMediator</code>'s
|
|
24
|
+
* <code>listNotificationInterests</code> method. The <code>IMediator</code> will
|
|
25
|
+
* return an <code>Array</code> of <code>INotification</code> names which
|
|
26
|
+
* it wishes to be notified about.</P>
|
|
27
|
+
*
|
|
28
|
+
* <P>
|
|
29
|
+
* The <code>IView</code> will then create an <code>Observer</code> object
|
|
30
|
+
* encapsulating that <code>IMediator</code>'s (<code>handleNotification</code>) method
|
|
31
|
+
* and register it as an Observer for each <code>INotification</code> name returned by
|
|
32
|
+
* <code>listNotificationInterests</code>.</P>
|
|
33
|
+
*
|
|
34
|
+
* @see INotification
|
|
35
|
+
*/
|
|
36
|
+
@protocol IMediator
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Get the <code>IMediator</code> instance name
|
|
40
|
+
*
|
|
41
|
+
* @return the <code>IMediator</code> instance name
|
|
42
|
+
*/
|
|
43
|
+
-(NSString *)mediatorName;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get the <code>IMediator</code>'s view component.
|
|
47
|
+
*
|
|
48
|
+
* @return id the view component
|
|
49
|
+
*/
|
|
50
|
+
-(id)viewComponent;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Handle an <code>INotification</code>.
|
|
54
|
+
*
|
|
55
|
+
* @param notification the <code>INotification</code> to be handled
|
|
56
|
+
*/
|
|
57
|
+
-(void)handleNotification:(id<INotification>)notification;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* List <code>INotification</code> interests.
|
|
61
|
+
*
|
|
62
|
+
* @return an <code>Array</code> of the <code>INotification</code> names this <code>IMediator</code> has an interest in.
|
|
63
|
+
*/
|
|
64
|
+
-(NSArray *)listNotificationInterests;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Called by the View when the Mediator is registered
|
|
68
|
+
*/
|
|
69
|
+
-(void)onRegister;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Called by the View when the Mediator is removed
|
|
73
|
+
*/
|
|
74
|
+
-(void)onRemove;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Set the <code>IMediator</code>'s view component.
|
|
78
|
+
*
|
|
79
|
+
* @param viewComponent the view component
|
|
80
|
+
*/
|
|
81
|
+
-(void)setViewComponent:(id)viewComponent;
|
|
82
|
+
|
|
83
|
+
@end
|
|
84
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#import "IProxy.h"
|
|
2
|
+
/**
|
|
3
|
+
* The interface definition for a PureMVC Model.
|
|
4
|
+
*
|
|
5
|
+
* <P>
|
|
6
|
+
* In PureMVC, <code>IModel</code> implementors provide
|
|
7
|
+
* access to <code>IProxy</code> objects by named lookup. </P>
|
|
8
|
+
*
|
|
9
|
+
* <P>
|
|
10
|
+
* An <code>IModel</code> assumes these responsibilities:</P>
|
|
11
|
+
*
|
|
12
|
+
* <UL>
|
|
13
|
+
* <LI>Maintain a cache of <code>IProxy</code> instances</LI>
|
|
14
|
+
* <LI>Provide methods for registering, retrieving, and removing <code>IProxy</code> instances</LI>
|
|
15
|
+
* </UL>
|
|
16
|
+
*/
|
|
17
|
+
@protocol IModel
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Check if a Proxy is registered
|
|
21
|
+
*
|
|
22
|
+
* @param proxyName
|
|
23
|
+
* @return whether a Proxy is currently registered with the given <code>proxyName</code>.
|
|
24
|
+
*/
|
|
25
|
+
-(BOOL)hasProxy:(NSString *)proxyName;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Register an <code>IProxy</code> instance with the <code>Model</code>.
|
|
29
|
+
*
|
|
30
|
+
* @param proxy an object reference to be held by the <code>Model</code>.
|
|
31
|
+
*/
|
|
32
|
+
-(void)registerProxy:(id<IProxy>)proxy;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Remove an <code>IProxy</code> instance from the Model.
|
|
36
|
+
*
|
|
37
|
+
* @param proxyName name of the <code>IProxy</code> instance to be removed.
|
|
38
|
+
* @return the <code>IProxy</code> that was removed from the <code>Model</code>
|
|
39
|
+
*/
|
|
40
|
+
-(id<IProxy>)removeProxy:(NSString *)proxyName;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Retrieve an <code>IProxy</code> instance from the Model.
|
|
44
|
+
*
|
|
45
|
+
* @param proxyName
|
|
46
|
+
* @return the <code>IProxy</code> instance previously registered with the given <code>proxyName</code>.
|
|
47
|
+
*/
|
|
48
|
+
-(id<IProxy>)retrieveProxy:(NSString *)proxyName;
|
|
49
|
+
|
|
50
|
+
@end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The interface definition for a PureMVC Notification.
|
|
3
|
+
*
|
|
4
|
+
* <P>
|
|
5
|
+
* PureMVC does not rely upon underlying event models such
|
|
6
|
+
* as the one provided with in AppKit or UIKit</P>
|
|
7
|
+
*
|
|
8
|
+
* <P>
|
|
9
|
+
* The Observer Pattern as implemented within PureMVC exists
|
|
10
|
+
* to support event-driven communication between the
|
|
11
|
+
* application and the actors of the MVC triad.</P>
|
|
12
|
+
*
|
|
13
|
+
* <P>
|
|
14
|
+
* Notifications are not meant to be a replacement for Events
|
|
15
|
+
* in AppKit or UIKit. Generally, <code>IMediator</code> implementors
|
|
16
|
+
* place event listeners on their view components, which they
|
|
17
|
+
* then handle in the usual way. This may lead to the broadcast of <code>Notification</code>s to
|
|
18
|
+
* trigger <code>ICommand</code>s or to communicate with other <code>IMediators</code>. <code>IProxy</code> and <code>ICommand</code>
|
|
19
|
+
* instances communicate with each other and <code>IMediator</code>s
|
|
20
|
+
* by broadcasting <code>INotification</code>s.</P>
|
|
21
|
+
*
|
|
22
|
+
* @see IView, IObserver
|
|
23
|
+
*/
|
|
24
|
+
@protocol INotification
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Get the body of the <code>INotification</code> instance
|
|
28
|
+
*/
|
|
29
|
+
-(id)body;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get the name of the <code>INotification</code> instance.
|
|
33
|
+
* No setter, should be set by constructor only
|
|
34
|
+
*/
|
|
35
|
+
-(NSString *)name;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Get the type of the <code>INotification</code> instance
|
|
39
|
+
*/
|
|
40
|
+
-(NSString *)type;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Set the body of the <code>INotification</code> instance
|
|
44
|
+
*/
|
|
45
|
+
-(void)setBody:(id)body;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Set the type of the <code>INotification</code> instance
|
|
49
|
+
*/
|
|
50
|
+
-(void)setType:(NSString *)type;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Get the string representation of the <code>INotification</code> instance
|
|
54
|
+
*/
|
|
55
|
+
-(NSString *)description;
|
|
56
|
+
|
|
57
|
+
@end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The interface definition for a PureMVC Notifier.
|
|
3
|
+
*
|
|
4
|
+
* <P>
|
|
5
|
+
* <code>MacroCommand, Command, Mediator</code> and <code>Proxy</code>
|
|
6
|
+
* all have a need to send <code>Notifications</code>. </P>
|
|
7
|
+
*
|
|
8
|
+
* <P>
|
|
9
|
+
* The <code>INotifier</code> interface provides a common method called
|
|
10
|
+
* <code>sendNotification</code> that relieves implementation code of
|
|
11
|
+
* the necessity to actually construct <code>Notifications</code>.</P>
|
|
12
|
+
*
|
|
13
|
+
* <P>
|
|
14
|
+
* The <code>Notifier</code> class, which all of the above mentioned classes
|
|
15
|
+
* extend, also provides an initialized reference to the <code>Facade</code>
|
|
16
|
+
* Singleton, which is required for the convienience method
|
|
17
|
+
* for sending <code>Notifications</code>, but also eases implementation as these
|
|
18
|
+
* classes have frequent <code>Facade</code> interactions and usually require
|
|
19
|
+
* access to the facade anyway.</P>
|
|
20
|
+
*
|
|
21
|
+
* @see IFacade, INotification
|
|
22
|
+
*/
|
|
23
|
+
@protocol INotifier
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Send a <code>INotification</code>.
|
|
27
|
+
*
|
|
28
|
+
* <P>
|
|
29
|
+
* Convenience method to prevent having to construct new
|
|
30
|
+
* notification instances in our implementation code.</P>
|
|
31
|
+
*
|
|
32
|
+
* @param notificationName the name of the notification to send
|
|
33
|
+
* @param body the body of the notification
|
|
34
|
+
* @param type the type of the notification
|
|
35
|
+
*/
|
|
36
|
+
-(void)sendNotification:(NSString *)notificationName body:(id)body type:(NSString *)type;
|
|
37
|
+
-(void)sendNotification:(NSString *)notificationName;
|
|
38
|
+
-(void)sendNotification:(NSString *)notificationName body:(id)body;
|
|
39
|
+
-(void)sendNotification:(NSString *)notificationName type:(NSString *)type;
|
|
40
|
+
|
|
41
|
+
@end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#import "INotification.h"
|
|
2
|
+
/**
|
|
3
|
+
* The interface definition for a PureMVC Observer.
|
|
4
|
+
*
|
|
5
|
+
* <P>
|
|
6
|
+
* In PureMVC, <code>IObserver</code> implementors assume these responsibilities:
|
|
7
|
+
* <UL>
|
|
8
|
+
* <LI>Encapsulate the notification (callback) method of the interested object.</LI>
|
|
9
|
+
* <LI>Encapsulate the notification context (this) of the interested object.</LI>
|
|
10
|
+
* <LI>Provide methods for setting the interested object' notification method and context.</LI>
|
|
11
|
+
* <LI>Provide a method for notifying the interested object.</LI>
|
|
12
|
+
* </UL>
|
|
13
|
+
*
|
|
14
|
+
* <P>
|
|
15
|
+
* The Observer Pattern as implemented within
|
|
16
|
+
* PureMVC exists to support event driven communication
|
|
17
|
+
* between the application and the actors of the
|
|
18
|
+
* MVC triad.</P>
|
|
19
|
+
*
|
|
20
|
+
* <P>
|
|
21
|
+
* An Observer is an object that encapsulates information
|
|
22
|
+
* about an interested object with a notification method that
|
|
23
|
+
* should be called when an </code>INotification</code> is broadcast. The Observer then
|
|
24
|
+
* acts as a proxy for notifying the interested object.
|
|
25
|
+
*
|
|
26
|
+
* <P>
|
|
27
|
+
* Observers can receive <code>Notification</code>s by having their
|
|
28
|
+
* <code>notifyObserver</code> method invoked, passing
|
|
29
|
+
* in an object implementing the <code>INotification</code> interface, such
|
|
30
|
+
* as a subclass of <code>Notification</code>.</P>
|
|
31
|
+
*
|
|
32
|
+
* @see IView, INotification
|
|
33
|
+
*/
|
|
34
|
+
@protocol IObserver
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Compare the given object to the notificaiton context object.
|
|
38
|
+
*
|
|
39
|
+
* @param object the object to compare.
|
|
40
|
+
* @return boolean indicating if the notification context and the object are the same.
|
|
41
|
+
*/
|
|
42
|
+
-(BOOL)compareNotifyContext:(id)object;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Notify the interested object.
|
|
46
|
+
*
|
|
47
|
+
* @param notification the <code>INotification</code> to pass to the interested object's notification method
|
|
48
|
+
*/
|
|
49
|
+
-(void)notifyObserver:(id<INotification>)notification;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Set the notification context.
|
|
53
|
+
*
|
|
54
|
+
* @param notifyContext the notification context (self) of the interested object
|
|
55
|
+
*/
|
|
56
|
+
-(void)setNotifyContext:(id)notifyContext;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Set the notification method.
|
|
60
|
+
*
|
|
61
|
+
* <P>
|
|
62
|
+
* The notification method should take one parameter of type <code>INotification</code></P>
|
|
63
|
+
*
|
|
64
|
+
* @param notifyMethod the notification (callback) selector of the interested object
|
|
65
|
+
*/
|
|
66
|
+
-(void)setNotifyMethod:(SEL)notifyMethod;
|
|
67
|
+
@end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The interface definition for a PureMVC Proxy.
|
|
3
|
+
*
|
|
4
|
+
* <P>
|
|
5
|
+
* In PureMVC, <code>IProxy</code> implementors assume these responsibilities:</P>
|
|
6
|
+
* <UL>
|
|
7
|
+
* <LI>Implement a common method which returns the name of the Proxy.</LI>
|
|
8
|
+
* <LI>Provide methods for setting and getting the data object.</LI>
|
|
9
|
+
* </UL>
|
|
10
|
+
* <P>
|
|
11
|
+
* Additionally, <code>IProxy</code>s typically:</P>
|
|
12
|
+
* <UL>
|
|
13
|
+
* <LI>Maintain references to one or more pieces of model data.</LI>
|
|
14
|
+
* <LI>Provide methods for manipulating that data.</LI>
|
|
15
|
+
* <LI>Generate <code>INotifications</code> when their model data changes.</LI>
|
|
16
|
+
* <LI>Expose their name as a <code>static method</code> called <code>NAME</code>, if they are not instantiated multiple times.</LI>
|
|
17
|
+
* <LI>Encapsulate interaction with local or remote services used to fetch and persist model data.</LI>
|
|
18
|
+
* </UL>
|
|
19
|
+
*/
|
|
20
|
+
@protocol IProxy
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Get the data object
|
|
24
|
+
*
|
|
25
|
+
* @return the data as type id
|
|
26
|
+
*/
|
|
27
|
+
-(id)data;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get the Proxy name
|
|
31
|
+
*
|
|
32
|
+
* @return the Proxy instance name
|
|
33
|
+
*/
|
|
34
|
+
-(NSString *)proxyName;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Called by the Model when the Proxy is registered
|
|
38
|
+
*/
|
|
39
|
+
-(void)onRegister;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Called by the Model when the Proxy is removed
|
|
43
|
+
*/
|
|
44
|
+
-(void)onRemove;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Set the data object
|
|
48
|
+
*
|
|
49
|
+
* @param data the data object
|
|
50
|
+
*/
|
|
51
|
+
-(void)setData:(id)data;
|
|
52
|
+
|
|
53
|
+
@end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#import "INotification.h"
|
|
2
|
+
#import "IMediator.h"
|
|
3
|
+
#import "IObserver.h"
|
|
4
|
+
/**
|
|
5
|
+
* The interface definition for a PureMVC View.
|
|
6
|
+
*
|
|
7
|
+
* <P>
|
|
8
|
+
* In PureMVC, <code>IView</code> implementors assume these responsibilities:</P>
|
|
9
|
+
*
|
|
10
|
+
* <P>
|
|
11
|
+
* In PureMVC, the <code>View</code> class assumes these responsibilities:
|
|
12
|
+
* <UL>
|
|
13
|
+
* <LI>Maintain a cache of <code>IMediator</code> instances.</LI>
|
|
14
|
+
* <LI>Provide methods for registering, retrieving, and removing <code>IMediators</code>.</LI>
|
|
15
|
+
* <LI>Managing the observer lists for each <code>INotification</code> in the application.</LI>
|
|
16
|
+
* <LI>Providing a method for attaching <code>IObservers</code> to an <code>INotification</code>'s observer list.</LI>
|
|
17
|
+
* <LI>Providing a method for broadcasting an <code>INotification</code>.</LI>
|
|
18
|
+
* <LI>Notifying the <code>IObservers</code> of a given <code>INotification</code> when it broadcast.</LI>
|
|
19
|
+
* </UL>
|
|
20
|
+
*
|
|
21
|
+
* @see IMediator, IObserver, INotification
|
|
22
|
+
*/
|
|
23
|
+
@protocol IView
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Check if a Mediator is registered or not
|
|
27
|
+
*
|
|
28
|
+
* @param mediatorName
|
|
29
|
+
* @return whether a Mediator is registered with the given <code>mediatorName</code>.
|
|
30
|
+
*/
|
|
31
|
+
-(BOOL)hasMediator:(NSString *)mediatorName;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Notify the <code>IObservers</code> for a particular <code>INotification</code>.
|
|
35
|
+
*
|
|
36
|
+
* <P>
|
|
37
|
+
* All previously attached <code>IObservers</code> for this <code>INotification</code>'s
|
|
38
|
+
* list are notified and are passed a reference to the <code>INotification</code> in
|
|
39
|
+
* the order in which they were registered.</P>
|
|
40
|
+
*
|
|
41
|
+
* @param notification the <code>INotification</code> to notify <code>IObservers</code> of.
|
|
42
|
+
*/
|
|
43
|
+
-(void)notifyObservers:(id<INotification>)notification;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Register an <code>IMediator</code> instance with the <code>View</code>.
|
|
47
|
+
*
|
|
48
|
+
* <P>
|
|
49
|
+
* Registers the <code>IMediator</code> so that it can be retrieved by name,
|
|
50
|
+
* and further interrogates the <code>IMediator</code> for its
|
|
51
|
+
* <code>INotification</code> interests.</P>
|
|
52
|
+
* <P>
|
|
53
|
+
* If the <code>IMediator</code> returns any <code>INotification</code>
|
|
54
|
+
* names to be notified about, an <code>Observer</code> is created encapsulating
|
|
55
|
+
* the <code>IMediator</code> instance's <code>handleNotification</code> method
|
|
56
|
+
* and registering it as an <code>Observer</code> for all <code>INotifications</code> the
|
|
57
|
+
* <code>IMediator</code> is interested in.</p>
|
|
58
|
+
*
|
|
59
|
+
* @param mediator a reference to the <code>IMediator</code> instance
|
|
60
|
+
*/
|
|
61
|
+
-(void)registerMediator:(id<IMediator>)mediator;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Register an <code>IObserver</code> to be notified
|
|
65
|
+
* of <code>INotifications</code> with a given name.
|
|
66
|
+
*
|
|
67
|
+
* @param notificationName the name of the <code>INotifications</code> to notify this <code>IObserver</code> of
|
|
68
|
+
* @param observer the <code>IObserver</code> to register
|
|
69
|
+
*/
|
|
70
|
+
-(void)registerObserver:(NSString *)notificationName observer:(id<IObserver>)observer;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Remove an <code>IMediator</code> from the <code>View</code>.
|
|
74
|
+
*
|
|
75
|
+
* @param mediatorName name of the <code>IMediator</code> instance to be removed.
|
|
76
|
+
* @return the <code>IMediator</code> that was removed from the <code>View</code>
|
|
77
|
+
*/
|
|
78
|
+
-(id<IMediator>)removeMediator:(NSString *)mediatorName;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Remove a group of observers from the observer list for a given Notification name.
|
|
82
|
+
* <P>
|
|
83
|
+
* @param notificationName which observer list to remove from
|
|
84
|
+
* @param notifyContext removed the observers with this object as their notifyContext
|
|
85
|
+
*/
|
|
86
|
+
-(void)removeObserver:(NSString *)notificationName notifyContext:(id)notifyContext;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Retrieve an <code>IMediator</code> from the <code>View</code>.
|
|
90
|
+
*
|
|
91
|
+
* @param mediatorName the name of the <code>IMediator</code> instance to retrieve.
|
|
92
|
+
* @return the <code>IMediator</code> instance previously registered with the given <code>mediatorName</code>.
|
|
93
|
+
*/
|
|
94
|
+
-(id<IMediator>)retrieveMediator:(NSString *)mediatorName;
|
|
95
|
+
|
|
96
|
+
@end
|