SSOperations 0.1.0

SSOperations 0.1.0

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

Maintained by Jonathan Hersh.


Downloads

Total7,525
Week0
Month0

Installs

Apps15
Test Targets5
Watch Apps2
powered by Segment

GitHub

Stars12
Watchers5
Forks3
Issues0
Contributors3
Pull Requests0

Code

Files5
LOCLines of Code 75


  • 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)