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,51 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Proxy.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 "IProxy.h"
|
|
11
|
+
#import "Notifier.h"
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A base <code>IProxy</code> implementation.
|
|
15
|
+
*
|
|
16
|
+
* <P>
|
|
17
|
+
* In PureMVC, <code>Proxy</code> classes are used to manage parts of the
|
|
18
|
+
* application's data model. </P>
|
|
19
|
+
*
|
|
20
|
+
* <P>
|
|
21
|
+
* A <code>Proxy</code> might simply manage a reference to a local data object,
|
|
22
|
+
* in which case interacting with it might involve setting and
|
|
23
|
+
* getting of its data in synchronous fashion.</P>
|
|
24
|
+
*
|
|
25
|
+
* <P>
|
|
26
|
+
* <code>Proxy</code> classes are also used to encapsulate the application's
|
|
27
|
+
* interaction with remote services to save or retrieve data, in which case,
|
|
28
|
+
* we adopt an asyncronous idiom; setting data (or calling a method) on the
|
|
29
|
+
* <code>Proxy</code> and listening for a <code>Notification</code> to be sent
|
|
30
|
+
* when the <code>Proxy</code> has retrieved the data from the service. </P>
|
|
31
|
+
*
|
|
32
|
+
* @see Model
|
|
33
|
+
*/
|
|
34
|
+
@interface Proxy : Notifier <IProxy> {
|
|
35
|
+
id data;
|
|
36
|
+
NSString *proxyName;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@property(nonatomic, retain) id data;
|
|
40
|
+
@property(nonatomic, retain) NSString *proxyName;
|
|
41
|
+
|
|
42
|
+
+(id)proxy;
|
|
43
|
+
+(id)withProxyName:(NSString *)proxyName;
|
|
44
|
+
+(id)withProxyName:(NSString *)proxyName data:(id)data;
|
|
45
|
+
+(id)withData:(id)data;
|
|
46
|
+
-(id)initWithProxyName:(NSString *)proxyName data:(id)data;
|
|
47
|
+
-(void)initializeProxy;
|
|
48
|
+
|
|
49
|
+
+(NSString *)NAME;
|
|
50
|
+
|
|
51
|
+
@end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Proxy.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 "Proxy.h"
|
|
10
|
+
|
|
11
|
+
@implementation Proxy
|
|
12
|
+
|
|
13
|
+
@synthesize data, proxyName;
|
|
14
|
+
|
|
15
|
+
+(id)proxy {
|
|
16
|
+
return [[[self alloc] initWithProxyName:nil data:nil] autorelease];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
+(id)withProxyName:(NSString *)proxyName {
|
|
20
|
+
return [[[self alloc] initWithProxyName:proxyName data:nil] autorelease];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
+(id)withProxyName:(NSString *)proxyName data:(id)data {
|
|
24
|
+
return [[[self alloc] initWithProxyName:proxyName data:data] autorelease];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
+(id)withData:(id)data {
|
|
28
|
+
return [[[self alloc] initWithProxyName:nil data:data] autorelease];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
-(id)initWithProxyName:(NSString *)_proxyName data:(id)_data {
|
|
32
|
+
if (self = [super init]) {
|
|
33
|
+
self.proxyName = (_proxyName == nil) ? [[self class] NAME] : _proxyName;
|
|
34
|
+
self.data = _data;
|
|
35
|
+
[self initializeProxy];
|
|
36
|
+
}
|
|
37
|
+
return self;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
+(NSString *)NAME {
|
|
41
|
+
return @"Proxy";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Initialize the Proxy instance.
|
|
46
|
+
*
|
|
47
|
+
* <P>
|
|
48
|
+
* Called automatically by the constructor, this
|
|
49
|
+
* is your opportunity to initialize the Proxy
|
|
50
|
+
* instance in your subclass without overriding the
|
|
51
|
+
* constructor.</P>
|
|
52
|
+
*
|
|
53
|
+
* @return void
|
|
54
|
+
*/
|
|
55
|
+
-(void)initializeProxy {}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Called by the Model when the Proxy is registered
|
|
59
|
+
*/
|
|
60
|
+
-(void)onRegister {}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Called by the Model when the Proxy is removed
|
|
64
|
+
*/
|
|
65
|
+
-(void)onRemove {}
|
|
66
|
+
|
|
67
|
+
-(void)dealloc {
|
|
68
|
+
self.data = nil;
|
|
69
|
+
self.proxyName = nil;
|
|
70
|
+
[super dealloc];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//
|
|
2
|
+
// ApplicationFacade.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 <UIKit/UIKit.h>
|
|
10
|
+
#import "Facade.h"
|
|
11
|
+
|
|
12
|
+
#define Startup @"Startup"
|
|
13
|
+
#define ShowNewUser @"ShowNewUser"
|
|
14
|
+
#define ShowEditUser @"ShowEditUser"
|
|
15
|
+
#define ShowUserForm @"ShowUserForm"
|
|
16
|
+
#define ShowUserList @"ShowUserList"
|
|
17
|
+
#define ShowError @"ShowError"
|
|
18
|
+
#define CreateUser @"CreateUser"
|
|
19
|
+
#define UpdateUser @"UpdateUser"
|
|
20
|
+
#define DeleteUser @"DeleteUser"
|
|
21
|
+
#define GetUsers @"GetUsers"
|
|
22
|
+
#define GetUsersSuccess @"GetUsersSuccess"
|
|
23
|
+
|
|
24
|
+
@interface ApplicationFacade : Facade {
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
+(ApplicationFacade *)getInstance;
|
|
28
|
+
|
|
29
|
+
-(void)startup:(id)app;
|
|
30
|
+
|
|
31
|
+
@end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//
|
|
2
|
+
// ApplicationFacade.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 "ApplicationFacade.h"
|
|
10
|
+
#import "StartupCommand.h"
|
|
11
|
+
#import "CreateUserCommand.h"
|
|
12
|
+
#import "UpdateUserCommand.h"
|
|
13
|
+
#import "GetUsersCommand.h"
|
|
14
|
+
|
|
15
|
+
@implementation ApplicationFacade
|
|
16
|
+
|
|
17
|
+
-(void)startup:(id)app {
|
|
18
|
+
[self sendNotification:Startup body:app];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
+(ApplicationFacade *)getInstance {
|
|
22
|
+
return (ApplicationFacade *)[super getInstance];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
-(void)initializeController {
|
|
26
|
+
[super initializeController];
|
|
27
|
+
[self registerCommand:Startup commandClassRef:[StartupCommand class]];
|
|
28
|
+
[self registerCommand:CreateUser commandClassRef:[CreateUserCommand class]];
|
|
29
|
+
[self registerCommand:UpdateUser commandClassRef:[UpdateUserCommand class]];
|
|
30
|
+
[self registerCommand:GetUsers commandClassRef:[GetUsersCommand class]];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//
|
|
2
|
+
// CreateUserCommand.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 "SimpleCommand.h"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@interface CreateUserCommand : SimpleCommand {
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// CreateUserCommand.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 "CreateUserCommand.h"
|
|
10
|
+
#import "ApplicationFacade.h"
|
|
11
|
+
#import "UserProxy.h"
|
|
12
|
+
#import "UserVO.h"
|
|
13
|
+
|
|
14
|
+
@implementation CreateUserCommand
|
|
15
|
+
|
|
16
|
+
-(void)execute:(id<INotification>)notification {
|
|
17
|
+
UserProxy *userProxy = (UserProxy *)[facade retrieveProxy:[UserProxy NAME]];
|
|
18
|
+
UserVO *userVO = [notification body];
|
|
19
|
+
if ([userVO isValid]) {
|
|
20
|
+
[userProxy create:userVO];
|
|
21
|
+
[facade sendNotification:ShowUserList];
|
|
22
|
+
} else {
|
|
23
|
+
[facade sendNotification:ShowError body:@"Invalid User"];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//
|
|
2
|
+
// DeleteUserCommand.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 "SimpleCommand.h"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@interface DeleteUserCommand : SimpleCommand {
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//
|
|
2
|
+
// DeleteUserCommand.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 "DeleteUserCommand.h"
|
|
10
|
+
#import "UserProxy.h"
|
|
11
|
+
#import "UserVO.h"
|
|
12
|
+
|
|
13
|
+
@implementation DeleteUserCommand
|
|
14
|
+
|
|
15
|
+
-(void)execute:(id<INotification>)notification {
|
|
16
|
+
UserProxy *userProxy = (UserProxy *)[facade retrieveProxy:[UserProxy NAME]];
|
|
17
|
+
UserVO *userVO = [notification body];
|
|
18
|
+
[userProxy delete:userVO];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//
|
|
2
|
+
// GetUsersCommand.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
|
+
|
|
10
|
+
#import "SimpleCommand.h"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@interface GetUsersCommand : SimpleCommand {
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//
|
|
2
|
+
// GetUsersCommand.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
|
+
|
|
10
|
+
#import "GetUsersCommand.h"
|
|
11
|
+
#import "ApplicationFacade.h"
|
|
12
|
+
#import "UserProxy.h"
|
|
13
|
+
|
|
14
|
+
@implementation GetUsersCommand
|
|
15
|
+
|
|
16
|
+
-(void)execute:(id<INotification>)notification {
|
|
17
|
+
UserProxy *userProxy = (UserProxy *)[facade retrieveProxy:[UserProxy NAME]];
|
|
18
|
+
[facade sendNotification:GetUsersSuccess body:userProxy.data];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//
|
|
2
|
+
// StartupCommand.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 <UIKit/UIKit.h>
|
|
10
|
+
#import "SimpleCommand.h"
|
|
11
|
+
|
|
12
|
+
@interface StartupCommand : SimpleCommand {
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//
|
|
2
|
+
// StartupCommand.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 "StartupCommand.h"
|
|
10
|
+
#import "Contacts.h"
|
|
11
|
+
#import "ApplicationFacade.h"
|
|
12
|
+
#import "UserListMediator.h"
|
|
13
|
+
#import "UserProxy.h"
|
|
14
|
+
#import "ContactsMediator.h"
|
|
15
|
+
#import "UserFormMediator.h"
|
|
16
|
+
|
|
17
|
+
@implementation StartupCommand
|
|
18
|
+
|
|
19
|
+
-(void)execute:(id<INotification>)notification {
|
|
20
|
+
[facade registerProxy:[UserProxy proxy]];
|
|
21
|
+
|
|
22
|
+
Contacts *app = [notification body];
|
|
23
|
+
|
|
24
|
+
[facade registerMediator:[ContactsMediator withViewComponent:app]];
|
|
25
|
+
[facade registerMediator:[UserListMediator withViewComponent:app.userList]];
|
|
26
|
+
[facade registerMediator:[UserFormMediator withViewComponent:app.userForm]];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//
|
|
2
|
+
// UpdateUserCommand.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 "SimpleCommand.h"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@interface UpdateUserCommand : SimpleCommand {
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// UpdateUserCommand.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 "UpdateUserCommand.h"
|
|
10
|
+
#import "ApplicationFacade.h"
|
|
11
|
+
#import "UserProxy.h"
|
|
12
|
+
#import "UserVO.h"
|
|
13
|
+
|
|
14
|
+
@implementation UpdateUserCommand
|
|
15
|
+
|
|
16
|
+
-(void)execute:(id<INotification>)notification {
|
|
17
|
+
UserProxy *userProxy = (UserProxy *)[facade retrieveProxy:[UserProxy NAME]];
|
|
18
|
+
UserVO *userVO = [notification body];
|
|
19
|
+
if ([userVO isValid]) {
|
|
20
|
+
[userProxy update:userVO];
|
|
21
|
+
[facade sendNotification:ShowUserList];
|
|
22
|
+
} else {
|
|
23
|
+
[facade sendNotification:ShowError body:@"Invalid User"];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//
|
|
2
|
+
// UserProxy.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 <UIKit/UIKit.h>
|
|
10
|
+
#import "Proxy.h"
|
|
11
|
+
|
|
12
|
+
@interface UserProxy : Proxy {
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
-(void)create:(id)item;
|
|
16
|
+
-(void)update:(id)item;
|
|
17
|
+
-(void)delete:(id)item;
|
|
18
|
+
|
|
19
|
+
@end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//
|
|
2
|
+
// UserProxy.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 "UserProxy.h"
|
|
10
|
+
#import "UserVO.h"
|
|
11
|
+
|
|
12
|
+
@implementation UserProxy
|
|
13
|
+
|
|
14
|
+
-(void)initializeProxy {
|
|
15
|
+
[super initializeProxy];
|
|
16
|
+
self.proxyName = [UserProxy NAME];
|
|
17
|
+
self.data = [NSMutableArray array];
|
|
18
|
+
[self create:[UserVO withUserName:@"lstooge" firstName:@"Larry" lastName:@"Stooge" email:@"larry@stooges.com" password:@"ijk456" confirmPassword:@"ijk456" department:@"Accounting"]];
|
|
19
|
+
[self create:[UserVO withUserName:@"cstooge" firstName:@"Curly" lastName:@"Stooge" email:@"curly@stooges.com" password:@"xyz987" confirmPassword:@"xyz987" department:@"Sales"]];
|
|
20
|
+
[self create:[UserVO withUserName:@"mstooge" firstName:@"Moe" lastName:@"Stooge" email:@"moe@stooges.com" password:@"abc123" confirmPassword:@"abc123" department:@"Plant"]];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
+(NSString *)NAME {
|
|
24
|
+
return @"UserProxy";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
-(NSMutableArray *)data {
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
-(void)create:(id)item {
|
|
32
|
+
[self.data addObject:item];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
-(void)update:(id)item {
|
|
36
|
+
for (int i=0; i<[self.data count]; i++) {
|
|
37
|
+
UserVO *userVO = [self.data objectAtIndex:i];
|
|
38
|
+
if ([userVO.username isEqualToString:[item username]]) {
|
|
39
|
+
[self.data replaceObjectAtIndex:i withObject:item];
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
-(void)delete:(id)item {
|
|
46
|
+
for (int i=0; i<[self.data count]; i++) {
|
|
47
|
+
UserVO *userVO = [self.data objectAtIndex:i];
|
|
48
|
+
if ([userVO.username isEqualToString:[item username]]) {
|
|
49
|
+
[self.data removeObjectAtIndex:i];
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
-(void)dealloc {
|
|
56
|
+
[super dealloc];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@end
|