-
Notifications
You must be signed in to change notification settings - Fork 1
Home
AAMCommandKit is command pattern library for objective-c.
Document Writer needed! I'm not a primally English speaker, need some's help for good documentation.
Simply alloc and call execute.
AAMLogCommand *command = [AAMLogCommand commandWithString:@"Hello World"];
[command execute]; //prints "Hello World"
By using AAMSerialCommand or AAMParallelCommand, you can sequentially execute multiple command.
NSMutableArray *ar = [NSMutableArray arrayWithCapacity:5];
[ar addObject:[AAMLogCommand commandWithString:@"First Command"]];
[ar addObject:[AAMLogCommand commandWithString:@"Second Command"]];
[ar addObject:[AAMLogCommand commandWithString:@"Third Command"]];
AAMSerialCommand *command = [AAMSerialCommand commandWithCommands:ar];
[command execute];
You can use selector with AAMSelectorCommand.
AAMSelectorCommand *command = [AAMSelectorCommand commandWithTarget:self selector:@selector(mySelector)];
[command execute];
You can use block with AAMBlockCommand.
AAMBlockCommand *command = [AAMBlockCommand commandWithBlock:^(void){ doSomething }];
[command execute];
You can use both delegate and Notification for event handling.
AAMLogCommand *c = [AAMLogComamnd commandWithString:@"do something"];
c.delegate = self;
[c execute];
If your commands needs some setup. Write it here. _setupCommand is executed in the beginning of command execution.
write your own processing hrere.
-(void)_executeCommand{ // }
When you finished all your processing call one of following method.
Generally you use _dispatchComplete.
- [self _dispatchComplete];
- [self _dispatchCancel];
- [self _dispatchStopWithError:(NSError*)theError];
If your commands needs to release object. Do it here. _teardownCommand is executed at the end of command execution.