Skip to content

splinesoft/SSOperations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SSOperations

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)

About

Handy NSOperationQueue and NSBlockOperation helpers.

Resources

License

Stars

Watchers

Forks

Packages

No packages published