Skip to content

Instantly share code, notes, and snippets.

@netshade
Created December 6, 2013 19:28
Show Gist options
  • Save netshade/7830721 to your computer and use it in GitHub Desktop.
Save netshade/7830721 to your computer and use it in GitHub Desktop.
NSOperationQueue Usage
// 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