CocoaPods trunk is moving to be read-only. Read more on the blog, there are 14 months to go.
| TestsTested | ✗ | 
| LangLanguage | Obj-CObjective C | 
| License | MIT | 
| ReleasedLast Release | Dec 2014 | 
Maintained by Unclaimed.
Floc Commands is a neat collection of easy-to-use commands for Objective-C. A command usually contains a small part of synchronous or asynchronous logic and can be chained or nested as much as you like. Floc Commands comes with a bunch of handy commands such as:
All commands are sublcasses of FLCommand, which is designed to be used both synchronously or asynchronously.
To get started, create a subclass of FLCommand and override execute. When a command finishes execution,
it must always call didExecuteWithError:. If it executed successfully without any errors, you pass nil as an argument
or you can use didExecute for convenience. Assign a delegate to respond to commandWillExecute:,
command:didExecuteWithError: or commandCancelled:.
Floc Commands comes with some nice categories and macros to enable cool stuff like:
FLSQ(dowloadImage, convertImage, applyFilter, upload).stopsOnError(YES).retry(3)
        .intercept(showSuccessAlert, showErrorAlert)
        .slave(playJeopardyTheme.repeat(-1)).keepAlive.execute;In this example FLSQ (macro for FLSequenceCommand) executes all asynchronous commands one after another and will
retry to execute all commands if any errors occour. If the sequence fails, showErrorAlert will be executed,
else showSuccessAlert. playJeopardyTheme will repeat forever (-1) and will be executed along with the sequence and
gets cancelled, as soon as asynchronous operation is completed. Since we do not have a strong pointer to the command, we
call keepAlive to ensure the command will not be deallocated before it's completed. The lifecycle of the command will
be managed for you.
FLBC(^(FLBlockCommand *command) {
    NSLog(@"na");
    [command performSelector:@selector(didExecute) withObject:nil afterDelay:0.2];
}).repeat(16).flseq(FLBC(^(FLBlockCommand *command) {
    NSLog(@"Batman!");
    [command performSelector:@selector(didExecute) withObject:nil afterDelay:0.2];
})).repeat(-1).keepAlive.execute;This example creates a FLBlockCommand which repeats 16x followed by another FLBlockCommand. The sequence will repeat forever (-1)
There are handy macros for each command type. Check them out! See FLCommand+Floc.h
When working with asynchronous commands, you should keep a strong pointer to it, because otherwise it may be
deallocated before it finishes. Alternatively you can call keepAlive, so the lifecycle of the command will be
managed for you.
RequestDataCommand might take several seconds to complete, so it's a good idea to assign in to a property to keep the command alive.
self.requestCommand = [[[RequesteDataCommand alloc] init] execute];
// or
[[RequesteDataCommand alloc] init].keepAlive.execute;@implementation HelloWorldCommand
- (void)execute {
    [super execute];
    NSLog(@"Hello world!");
    [self didExecute];
}
@end@implementation SendDataCommand
- (void)execute {
    [super execute];
      // This may take a few seconds...
      [self.service sendData:data onComplete:^(NSError *error) {
          [self didExecuteWithError:error];
      }];
}
- (void)cancel {
    [self.service closeConnection];
    [super cancel];
}
@endExecutes commands one at a time. Available options:
stopOnError will stop, when an error occouredcancelOnCancel will cancel, when a sub command got cancelled[[FLSequenceCommand alloc] initWithCommands:@[c1, c2, c3, c4]];Executes commands all at once. Available options:
stopOnError will stop, when an error occouredcancelOnCancel will cancel, when a sub command got cancelled[[FLPrallelCommand alloc] initWithCommands:@[c1, c2, c3, c4]];Executes target command. The success commands gets executed when no errors occoured, else error command. Available options:
cancelOnCancel will cancel, when a sub command got cancelledforwardTargetError will forward the target error via command:didExecuteWithError:
self.postCommand = [[FLInterceptionCommand alloc] initWithTarget:sendDataCommand
                                                         success:hideSpinnerCommand
                                                           error:showErrorAlertCommand];
[self.postCommand execute];[[FLBlockCommand alloc] initWithBlock:^(FLBlockCommand *command) {
    NSLog(@"Hello world!");
    [command didExecute];
}];FLBlockCommand *delayCommand = [[FLBlockCommand alloc] initWithBlock:^(FLBlockCommand *command) {
    [command performSelector:@selector(didExecute) withObject:nil afterDelay:1];
}];Executes both commands at the same time and will cancel slave, as soon as the master command did execute. Available options:
forwardMasterError will forward the matser error via command:didExecuteWithError:
[[FLMasterSlaveCommand alloc] initWithMaster:doHeavyTaskCommand slave:playJeopardyMusicCommand];... and more (FLRepeatCommand, FLRetryCommand, FLDelayCommand)
You find the source files you need in Floc-Commands/Classes.
$ cd path/to/project
$ pod install
Open the created Xcode Workspace file.