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,35 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Mediator.h
|
|
3
|
+
// PureMVC_ObjectiveC
|
|
4
|
+
//
|
|
5
|
+
// PureMVC Port to ObjectiveC by Brian Knorr <brian.knorr@puremvc.org>
|
|
6
|
+
// PureMVC - Copyright(c) 2006-2008 Futurescale, Inc., Some rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import <Foundation/Foundation.h>
|
|
10
|
+
#import "IMediator.h"
|
|
11
|
+
#import "Notifier.h"
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A base <code>IMediator</code> implementation.
|
|
15
|
+
*
|
|
16
|
+
* @see View
|
|
17
|
+
*/
|
|
18
|
+
@interface Mediator : Notifier <IMediator> {
|
|
19
|
+
NSString *mediatorName;
|
|
20
|
+
id viewComponent;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@property(nonatomic, retain) id viewComponent;
|
|
24
|
+
@property(nonatomic, retain) NSString *mediatorName;
|
|
25
|
+
|
|
26
|
+
+(id)mediator;
|
|
27
|
+
+(id)withMediatorName:(NSString *)mediatorName;
|
|
28
|
+
+(id)withMediatorName:(NSString *)mediatorName viewComponent:(id)viewComponent;
|
|
29
|
+
+(id)withViewComponent:(id)viewComponent;
|
|
30
|
+
-(id)initWithMediatorName:(NSString *)mediatorName viewComponent:(id)viewComponent;
|
|
31
|
+
-(void)initializeMediator;
|
|
32
|
+
|
|
33
|
+
+(NSString *)NAME;
|
|
34
|
+
|
|
35
|
+
@end
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Mediator.m
|
|
3
|
+
// PureMVC_ObjectiveC
|
|
4
|
+
//
|
|
5
|
+
// PureMVC Port to ObjectiveC by Brian Knorr <brian.knorr@puremvc.org>
|
|
6
|
+
// PureMVC - Copyright(c) 2006-2008 Futurescale, Inc., Some rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import "Mediator.h"
|
|
10
|
+
|
|
11
|
+
@implementation Mediator
|
|
12
|
+
|
|
13
|
+
@synthesize mediatorName, viewComponent;
|
|
14
|
+
|
|
15
|
+
+(id)mediator {
|
|
16
|
+
return [[[self alloc] initWithMediatorName:nil viewComponent:nil] autorelease];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
+(id)withMediatorName:(NSString *)mediatorName {
|
|
20
|
+
return [[[self alloc] initWithMediatorName:mediatorName viewComponent:nil] autorelease];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
+(id)withMediatorName:(NSString *)mediatorName viewComponent:(id)viewComponent {
|
|
24
|
+
return [[[self alloc] initWithMediatorName:mediatorName viewComponent:viewComponent] autorelease];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
+(id)withViewComponent:(id)viewComponent {
|
|
28
|
+
return [[[self alloc] initWithMediatorName:nil viewComponent:viewComponent] autorelease];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
-(id)initWithMediatorName:(NSString *)_mediatorName viewComponent:(id)_viewComponent {
|
|
32
|
+
if (self = [super init]) {
|
|
33
|
+
self.mediatorName = (_mediatorName == nil) ? [[self class] NAME] : _mediatorName;
|
|
34
|
+
self.viewComponent = _viewComponent;
|
|
35
|
+
[self initializeMediator];
|
|
36
|
+
}
|
|
37
|
+
return self;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The name of the <code>Mediator</code>.
|
|
42
|
+
*
|
|
43
|
+
* <P>
|
|
44
|
+
* Typically, a <code>Mediator</code> will be written to serve
|
|
45
|
+
* one specific control or group controls and so,
|
|
46
|
+
* will not have a need to be dynamically named.</P>
|
|
47
|
+
*/
|
|
48
|
+
+(NSString *)NAME {
|
|
49
|
+
return @"Mediator";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Initialize the Mediator instance.
|
|
54
|
+
*
|
|
55
|
+
* <P>
|
|
56
|
+
* Called automatically by the constructor, this
|
|
57
|
+
* is your opportunity to initialize the Mediator
|
|
58
|
+
* instance in your subclass without overriding the
|
|
59
|
+
* constructor.</P>
|
|
60
|
+
*
|
|
61
|
+
* @return void
|
|
62
|
+
*/
|
|
63
|
+
-(void)initializeMediator {}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Handle <code>INotification</code>s.
|
|
67
|
+
*
|
|
68
|
+
* <P>
|
|
69
|
+
* Typically this will be handled in a switch statement,
|
|
70
|
+
* with one 'case' entry per <code>INotification</code>
|
|
71
|
+
* the <code>Mediator</code> is interested in.
|
|
72
|
+
*/
|
|
73
|
+
-(void)handleNotification:(id<INotification>)notification {}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* List the <code>INotification</code> names this
|
|
77
|
+
* <code>Mediator</code> is interested in being notified of.
|
|
78
|
+
*
|
|
79
|
+
* @return Array the list of <code>INotification</code> names
|
|
80
|
+
*/
|
|
81
|
+
-(NSArray *)listNotificationInterests {
|
|
82
|
+
return [NSArray array];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Called by the View when the Mediator is registered
|
|
87
|
+
*/
|
|
88
|
+
-(void)onRegister {}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Called by the View when the Mediator is removed
|
|
92
|
+
*/
|
|
93
|
+
-(void)onRemove {}
|
|
94
|
+
|
|
95
|
+
-(void)dealloc {
|
|
96
|
+
self.mediatorName = nil;
|
|
97
|
+
self.viewComponent = nil;
|
|
98
|
+
[super dealloc];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Notification.h
|
|
3
|
+
// PureMVC_ObjectiveC
|
|
4
|
+
//
|
|
5
|
+
// PureMVC Port to ObjectiveC by Brian Knorr <brian.knorr@puremvc.org>
|
|
6
|
+
// PureMVC - Copyright(c) 2006-2008 Futurescale, Inc., Some rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import <Foundation/Foundation.h>
|
|
10
|
+
#import "INotification.h"
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A base <code>INotification</code> implementation.
|
|
14
|
+
*
|
|
15
|
+
* <P>
|
|
16
|
+
* PureMVC does not rely upon underlying event models such
|
|
17
|
+
* as the one provided with in AppKit or UIKit</P>
|
|
18
|
+
*
|
|
19
|
+
* <P>
|
|
20
|
+
* The Observer Pattern as implemented within PureMVC exists
|
|
21
|
+
* to support event-driven communication between the
|
|
22
|
+
* application and the actors of the MVC triad.</P>
|
|
23
|
+
*
|
|
24
|
+
* <P>
|
|
25
|
+
* Notifications are not meant to be a replacement for Events
|
|
26
|
+
* in AppKit or UIKit. Generally, <code>IMediator</code> implementors
|
|
27
|
+
* place event listeners on their view components, which they
|
|
28
|
+
* then handle in the usual way. This may lead to the broadcast of <code>Notification</code>s to
|
|
29
|
+
* trigger <code>ICommand</code>s or to communicate with other <code>IMediators</code>. <code>IProxy</code> and <code>ICommand</code>
|
|
30
|
+
* instances communicate with each other and <code>IMediator</code>s
|
|
31
|
+
* by broadcasting <code>INotification</code>s.</P>
|
|
32
|
+
*
|
|
33
|
+
* @see Observer
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
@interface Notification : NSObject <INotification> {
|
|
37
|
+
NSString *name, *type;
|
|
38
|
+
id body;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@property(nonatomic, retain) NSString *name;
|
|
42
|
+
@property(nonatomic, retain) NSString *type;
|
|
43
|
+
@property(nonatomic, retain) id body;
|
|
44
|
+
|
|
45
|
+
+(id)withName:(NSString *)name body:(id)body type:(NSString *)type;
|
|
46
|
+
+(id)withName:(NSString *)nam;
|
|
47
|
+
+(id)withName:(NSString *)name body:(id)body;
|
|
48
|
+
+(id)withName:(NSString *)name type:(NSString *)type;
|
|
49
|
+
-(id)initWithName:(NSString *)name body:(id)body type:(NSString *)type;
|
|
50
|
+
-(NSString *)description;
|
|
51
|
+
|
|
52
|
+
@end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Notification.m
|
|
3
|
+
// PureMVC_ObjectiveC
|
|
4
|
+
//
|
|
5
|
+
// PureMVC Port to ObjectiveC by Brian Knorr <brian.knorr@puremvc.org>
|
|
6
|
+
// PureMVC - Copyright(c) 2006-2008 Futurescale, Inc., Some rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import "Notification.h"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@implementation Notification
|
|
13
|
+
|
|
14
|
+
@synthesize name, body, type;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Static Convienence Constructor.
|
|
18
|
+
*
|
|
19
|
+
* @param name name of the <code>Notification</code> instance.
|
|
20
|
+
* @param body the <code>Notification</code> body.
|
|
21
|
+
* @param type the type of the <code>Notification</code>
|
|
22
|
+
*/
|
|
23
|
+
+(id)withName:(NSString *)name body:(id)body type:(NSString *)type {
|
|
24
|
+
return [[[self alloc] initWithName:name body:body type:type] autorelease];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
+(id)withName:(NSString *)name {
|
|
28
|
+
return [[[self alloc] initWithName:name body:nil type:nil] autorelease];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
+(id)withName:(NSString *)name body:(id)body {
|
|
32
|
+
return [[[self alloc] initWithName:name body:body type:nil] autorelease];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
+(id)withName:(NSString *)name type:(NSString *)type {
|
|
36
|
+
return [[[self alloc] initWithName:name body:nil type:type] autorelease];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Constructor.
|
|
41
|
+
*
|
|
42
|
+
* @param name name of the <code>Notification</code> instance.
|
|
43
|
+
* @param body the <code>Notification</code> body.
|
|
44
|
+
* @param type the type of the <code>Notification</code>
|
|
45
|
+
*/
|
|
46
|
+
-(id)initWithName:(NSString *)_name body:(id)_body type:(NSString *)_type {
|
|
47
|
+
if (self = [super init]) {
|
|
48
|
+
self.name = _name;
|
|
49
|
+
self.body = _body;
|
|
50
|
+
self.type = _type;
|
|
51
|
+
}
|
|
52
|
+
return self;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Get the string representation of the <code>Notification</code> instance.
|
|
57
|
+
*
|
|
58
|
+
* @return the string representation of the <code>Notification</code> instance.
|
|
59
|
+
*/
|
|
60
|
+
-(NSString *)description {
|
|
61
|
+
return [NSString stringWithFormat:@"Notification Name: %@ \nBody:%@ \nType:%@", name, body, type];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
-(void)dealloc {
|
|
65
|
+
self.name = nil;
|
|
66
|
+
self.body = nil;
|
|
67
|
+
self.type = nil;
|
|
68
|
+
[super dealloc];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Notifier.h
|
|
3
|
+
// PureMVC_ObjectiveC
|
|
4
|
+
//
|
|
5
|
+
// PureMVC Port to ObjectiveC by Brian Knorr <brian.knorr@puremvc.org>
|
|
6
|
+
// PureMVC - Copyright(c) 2006-2008 Futurescale, Inc., Some rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import <Foundation/Foundation.h>
|
|
10
|
+
#import "INotifier.h"
|
|
11
|
+
#import "IFacade.h"
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A Base <code>INotifier</code> implementation.
|
|
15
|
+
*
|
|
16
|
+
* <P>
|
|
17
|
+
* <code>MacroCommand, Command, Mediator</code> and <code>Proxy</code>
|
|
18
|
+
* all have a need to send <code>Notifications</code>. <P>
|
|
19
|
+
* <P>
|
|
20
|
+
* The <code>INotifier</code> interface provides a common method called
|
|
21
|
+
* <code>sendNotification</code> that relieves implementation code of
|
|
22
|
+
* the necessity to actually construct <code>Notifications</code>.</P>
|
|
23
|
+
*
|
|
24
|
+
* <P>
|
|
25
|
+
* The <code>Notifier</code> class, which all of the above mentioned classes
|
|
26
|
+
* extend, provides an initialized reference to the <code>Facade</code>
|
|
27
|
+
* Singleton, which is required for the convienience method
|
|
28
|
+
* for sending <code>Notifications</code>, but also eases implementation as these
|
|
29
|
+
* classes have frequent <code>Facade</code> interactions and usually require
|
|
30
|
+
* access to the facade anyway.</P>
|
|
31
|
+
*
|
|
32
|
+
* @see Facade, Mediator, Proxy, SimpleCommand, MacroCommand
|
|
33
|
+
*/
|
|
34
|
+
@interface Notifier : NSObject <INotifier> {
|
|
35
|
+
id<IFacade> facade;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@property(nonatomic, retain) id<IFacade> facade;
|
|
39
|
+
|
|
40
|
+
@end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Notifier.m
|
|
3
|
+
// PureMVC_ObjectiveC
|
|
4
|
+
//
|
|
5
|
+
// PureMVC Port to ObjectiveC by Brian Knorr <brian.knorr@puremvc.org>
|
|
6
|
+
// PureMVC - Copyright(c) 2006-2008 Futurescale, Inc., Some rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import "Notifier.h"
|
|
10
|
+
#import "Facade.h"
|
|
11
|
+
|
|
12
|
+
@implementation Notifier
|
|
13
|
+
|
|
14
|
+
@synthesize facade;
|
|
15
|
+
|
|
16
|
+
-(id)init {
|
|
17
|
+
if (self = [super init]) {
|
|
18
|
+
self.facade = [Facade getInstance];
|
|
19
|
+
}
|
|
20
|
+
return self;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Create and send an <code>INotification</code>.
|
|
25
|
+
*
|
|
26
|
+
* <P>
|
|
27
|
+
* Keeps us from having to construct new INotification
|
|
28
|
+
* instances in our implementation code.
|
|
29
|
+
* @param notificationName the name of the notiification to send
|
|
30
|
+
* @param body the body of the notification
|
|
31
|
+
* @param type the type of the notification
|
|
32
|
+
*/
|
|
33
|
+
-(void)sendNotification:(NSString *)notificationName body:(id)body type:(NSString *)type {
|
|
34
|
+
[facade sendNotification:notificationName body:body type:type];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
-(void)sendNotification:(NSString *)notificationName {
|
|
38
|
+
[self sendNotification:notificationName body:nil type:nil];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
-(void)sendNotification:(NSString *)notificationName body:(id)body {
|
|
42
|
+
[self sendNotification:notificationName body:body type:nil];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
-(void)sendNotification:(NSString *)notificationName type:(NSString *)type {
|
|
46
|
+
[self sendNotification:notificationName body:nil type:type];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
-(void)dealloc {
|
|
50
|
+
self.facade = nil;
|
|
51
|
+
[super dealloc];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Observer.h
|
|
3
|
+
// PureMVC_ObjectiveC
|
|
4
|
+
//
|
|
5
|
+
// PureMVC Port to ObjectiveC by Brian Knorr <brian.knorr@puremvc.org>
|
|
6
|
+
// PureMVC - Copyright(c) 2006-2008 Futurescale, Inc., Some rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import <Foundation/Foundation.h>
|
|
10
|
+
#import "IObserver.h"
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A base <code>IObserver</code> implementation.
|
|
14
|
+
*
|
|
15
|
+
* <P>
|
|
16
|
+
* An <code>Observer</code> is an object that encapsulates information
|
|
17
|
+
* about an interested object with a method that should
|
|
18
|
+
* be called when a particular <code>INotification</code> is broadcast. </P>
|
|
19
|
+
*
|
|
20
|
+
* <P>
|
|
21
|
+
* In PureMVC, the <code>Observer</code> class assumes these responsibilities:
|
|
22
|
+
* <UL>
|
|
23
|
+
* <LI>Encapsulate the notification (callback) method of the interested object.</LI>
|
|
24
|
+
* <LI>Encapsulate the notification context (this) of the interested object.</LI>
|
|
25
|
+
* <LI>Provide methods for setting the notification method and context.</LI>
|
|
26
|
+
* <LI>Provide a method for notifying the interested object.</LI>
|
|
27
|
+
* </UL>
|
|
28
|
+
*
|
|
29
|
+
* @see View, Notification
|
|
30
|
+
*/
|
|
31
|
+
@interface Observer : NSObject <IObserver> {
|
|
32
|
+
SEL notifyMethod;
|
|
33
|
+
id notifyContext;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@property SEL notifyMethod;
|
|
37
|
+
@property(nonatomic, retain) id notifyContext;
|
|
38
|
+
|
|
39
|
+
+(id)withNotifyMethod:(SEL)notifyMethod notifyContext:(id)notifyContext;
|
|
40
|
+
-(id)initWithNotifyMethod:(SEL)notifyMethod notifyContext:(id)notifyContext;
|
|
41
|
+
|
|
42
|
+
@end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Observer.m
|
|
3
|
+
// PureMVC_ObjectiveC
|
|
4
|
+
//
|
|
5
|
+
// PureMVC Port to ObjectiveC by Brian Knorr <brian.knorr@puremvc.org>
|
|
6
|
+
// PureMVC - Copyright(c) 2006-2008 Futurescale, Inc., Some rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import "Observer.h"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@implementation Observer
|
|
13
|
+
|
|
14
|
+
@synthesize notifyMethod, notifyContext;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Static Convienence Constructor.
|
|
18
|
+
*/
|
|
19
|
+
+(id)withNotifyMethod:(SEL)notifyMethod notifyContext:(id)notifyContext {
|
|
20
|
+
return [[[self alloc] initWithNotifyMethod:notifyMethod notifyContext:notifyContext] autorelease];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Constructor.
|
|
25
|
+
*
|
|
26
|
+
* <P>
|
|
27
|
+
* The notification method on the interested object should take
|
|
28
|
+
* one parameter of type <code>INotification</code></P>
|
|
29
|
+
*
|
|
30
|
+
* @param notifyMethod the notification method of the interested object
|
|
31
|
+
* @param notifyContext the notification context of the interested object
|
|
32
|
+
*/
|
|
33
|
+
-(id)initWithNotifyMethod:(SEL)_notifyMethod notifyContext:(id)_notifyContext {
|
|
34
|
+
if (self = [super init]) {
|
|
35
|
+
self.notifyMethod = _notifyMethod;
|
|
36
|
+
self.notifyContext = _notifyContext;
|
|
37
|
+
}
|
|
38
|
+
return self;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Compare an object to the notification context.
|
|
43
|
+
*
|
|
44
|
+
* @param object the object to compare
|
|
45
|
+
* @return boolean indicating if the object and the notification context are the same
|
|
46
|
+
*/
|
|
47
|
+
-(BOOL)compareNotifyContext:(id)object {
|
|
48
|
+
return [object isEqual:notifyContext];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Notify the interested object.
|
|
53
|
+
*
|
|
54
|
+
* @param notification the <code>INotification</code> to pass to the interested object's notification method.
|
|
55
|
+
*/
|
|
56
|
+
-(void)notifyObserver:(id<INotification>)notification {
|
|
57
|
+
[notifyContext performSelector:notifyMethod withObject:notification];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
-(void)dealloc {
|
|
61
|
+
self.notifyMethod = nil;
|
|
62
|
+
self.notifyContext = nil;
|
|
63
|
+
[super dealloc];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@end
|