Latest 0.1.0
Homepage https://github.com/splinesoft/SSOperations
License MIT
Platforms ios 6.0, requires ARC
Frameworks Foundation
Authors

Circle CI Coverage Status

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)

Latest podspec

{
    "name": "SSOperations",
    "version": "0.1.0",
    "summary": "Handy NSOperationQueue and NSBlockOperation helpers.",
    "homepage": "https://github.com/splinesoft/SSOperations",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Jonathan Hersh": "[email protected]"
    },
    "source": {
        "git": "https://github.com/splinesoft/SSOperations.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "6.0"
    },
    "requires_arc": true,
    "source_files": "SSOperations/*.{h,m}",
    "frameworks": "Foundation",
    "compiler_flags": "-fmodules"
}

Pin It on Pinterest

Share This