SSOperations 0.1.0

SSOperations 0.1.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Mar 2015

Maintained by Jonathan Hersh.



  • By
  • Jonathan Hersh

Circle CI

Handy NSOperationQueue and NSBlockOperation helpers.

SSOperations powers various operations in my app MUDRammer - a modern MUD client for iPhone and iPad.

Install

Install with CocoaPods. Add to your Podfile:

pod 'SSOperations', :head # YOLO

SSBlockOperation & SSBlockOperationBlock

A simple subclass of NSBlockOperation that is passed itself as input when executed.

The primary advantage is that you can inspect, at run-time, whether the operation has been canceled and if so, clean up and exit appropriately.

SSBlockOperationBlock anOperationBlock = ^(SSBlockOperation *operation) {
    if( [operation isCancelled] )
        return;

    // Do some stuff…

    if( [operation isCancelled] )
        return;

    // Do some more stuff...
};

// Submit this operation to a queue for execution.
[myOperationQueue ss_addBlockOperationWithBlock:anOperationBlock];

NSOperationQueue+SSAdditions.h

A handy way to create an NSOperationQueue and submit SSBlockOperationBlocks for execution.

// An operation queue that runs operations serially.
NSOperationQueue *serialQueue = [NSOperationQueue ss_serialOperationQueue];

// An operation queue that runs up to 3 operations concurrently.
NSOperationQueue *threeOperationQueue = [NSOperationQueue ss_concurrentQueueWithConcurrentOperations:3

// An operation queue that runs as many concurrent operations as the system deems appropriate.
// It has a name!
NSOperationQueue *concurrentQueue = [NSOperationQueue ss_concurrentMaxOperationQueueNamed:@"My queue"];

// Submit an `SSBlockOperationBlock` for processing.
[anOperationQueue ss_addBlockOperationWithBlock:anOperationBlock];

Thanks!

SSOperations is a @jhersh production -- (electronic mail | @jhersh)