Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Simple NSOperation subclass that allows a block of asynchronous work to be executed in parallel in a NSOperationQueue
Objective-C Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
Sample
.gitignore
LICENSE
README.md
RNConcurrentBlockOperation.h
RNConcurrentBlockOperation.m
RNConcurrentBlockOperation.podspec

README.md

RNConcurrentBlockOperation

RNConcurrentBlockOperation is a simple NSOperation subclass, similar to NSBlockOperation. It allows a block of work that is potentially asynchrounous to be submited into a NSOperationQueue for parallel execution.

Sample usage:

    NSOperationQueue *queue = [NSOperationQueue new];
    queue.maxConcurrentOperationCount = 5;
    // Regular usage, only finishes the operation
    [queue addOperation:[RNConcurrentBlockOperation operationWithBlock:^(RNCompletionBlock completion) {
        NSLog(@"Concurrent op started");
        //Some async operation
        //... ... ...
        //Async operation completed
        completion(nil);
    }]];
    // Cancelled operation, cancels then finish the operation
    [queue addOperation:[RNConcurrentBlockOperation operationWithBlock:^(RNCompletionBlock completion) {
        NSLog(@"Cancellable op started");
        //Some async operation
        //... ... ...
        //Something happened (i.e user cancelled, network outage), and we want to bail
        //Async operation cancelled
        NSError *error = [NSError new]; //Some possible error
        completion(@{RNOperationStatusKey: RNOperationStatusCanceled, RNOperationErrorKey: error});
    }]];
    // Store the operation value in the userInfo dictionary and finishes it.
    [queue addOperation:[RNConcurrentBlockOperation operationWithBlock:^(RNCompletionBlock completion) {
        NSLog(@"Concurrent op started with result");
        NSString *result = @"A string generated by the async operation";
        completion(@{RNOperationResultKey: result});
    }]];  
Something went wrong with that request. Please try again.