Latest 0.1.0
License MIT
Platforms ios 5.0, osx 10.7, requires ARC

CI Status

NSOperation subclass that manages the concurrent execution of a block.


You can use MROperation objects directly:

MROperation *someOperation = [[MROperation  alloc] initWithBlock:^(id<MRExecutingOperation> *operation) {
    // long running task...
    if (operation.isCancelled) return;
    // long running task...
    if (!operation.isFinished) [operation finishWithError:nil];

[someOperation start];

But you can also implement your own subclasses. See, for instance, how you could create a custom subclass for performing reverse-geocoding requests:

// MROperation subclass that performs reverse-geocoding requests.
@interface GeocodingRequestOperation : MROperation

// Returns a reverse-geocoding request operation for the given location.
+ (instancetype)operationWithLocation:(CLLocation *)location;

// The result of the reverse-geocoding request.
@property (nonatomic, strong) CLPlacemark *placemark;


@implementation GeocodingRequestOperation

+ (instancetype)operationWithLocation:(CLLocation *)location {
    return [[self alloc] initWithBlock:^(GeocodingRequestOperation<MRExecutingOperation> *operation) {
        [[[CLGeocoder alloc] init] reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
            operation.placemark = placemarks.firstObject;
            if (!operation.isFinished) [operation finishWithError:error];


And here’s how you would execute them:

// Set up a queue:
_geocodingQueue = [[NSOperationQueue alloc] init];
_geocodingQueue.maxConcurrentOperationCount = 1;

// Create and configure the reverse-geocoding request operation:
GeocodingRequestOperation *o = [GeocodingRequestOperation operationWithLocation:location];
[o setCompletionBlockWithSuccess:^(GeocodingRequestOperation *operation) {
    NSLog(@"Hello %@!",;
} failure:^{
    NSLog(@"%@", error);

// Add the operation to the queue:
[_geocodingQueue addOperation:o];

For another example on how to subclass MRoperation, you can refer to the MRDetectBpmOperation implementation.



MROperation is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "MROperation"


Drag the MROperation folder into your project.


MROperation is available under the MIT license. See the LICENSE file for more info.


Latest podspec

    "name": "MROperation",
    "version": "0.1.0",
    "summary": "NSOperation subclass that manages the concurrent execution of a block.",
    "description": "The `MROperation` class is a concrete subclass of `NSOperation` that manages the concurrent execution of a block.",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "hectr": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.1.0"
    "social_media_url": "",
    "platforms": {
        "ios": "5.0",
        "osx": "10.7"
    "requires_arc": true,
    "source_files": "MROperation"

Pin It on Pinterest

Share This