Completion block for NSOperationQueue.
Swift
import NSOperationQueue_CompletionBlock
let queue = NSOperationQueue()
queue.completionBlock = {
NSLog("I'm done!")
}
queue.addOperationWithBlock {
NSLog("I am an operation.")
}
Objective-C
#import <NSOperationQueue_CompletionBlock/NSOperationQueue+CompletionBlock.h>
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
queue.completionBlock = ^{
NSLog(@"I'm done!");
};
[queue addOperationWithBlock:^{
NSLog(@"I am an operation.");
}];
Output
I am an operation.
I'm done!
I recommend you to use CocoaPods, a dependency manager for Cocoa.
Podfile
pod 'NSOperationQueue+CompletionBlock', '~> 1.0'
NSOperationQueue+CompletionBlock is under MIT license. See the LICENSE file for more info.