Created
December 6, 2013 19:28
-
-
Save netshade/7830721 to your computer and use it in GitHub Desktop.
NSOperationQueue Usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// to initialize the nsoperationqueue | |
NSOperationQueue * queue = [[NSOperationQueue alloc] init]; | |
[queue setMaxConcurrentOperationCount:4]; | |
// to add an operation to the context | |
NSOperation * op = [NSBlockOperation blockOperationWithBlock:^{ | |
int i = 0; | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
// update ui | |
}); | |
}]; | |
[queue addOperation:op]; | |
// if you ever want to cancel the operation | |
[op cancel]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment