Skip to content

Instantly share code, notes, and snippets.

@marshluca
Created July 15, 2011 06:01
Show Gist options
  • Save marshluca/1084164 to your computer and use it in GitHub Desktop.
Save marshluca/1084164 to your computer and use it in GitHub Desktop.
NSOperationQueue,NSInvocationOperation
- (void) clickButton
{
NSOperationQueue *queue = [NSOperationQueue new];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(loadDataWithOperation)
object:nil];
[queue addOperation:operation]; // will start the operation
[operation release];
[UIApplicationsharedApplication].networkActivityIndicatorVisible = YES;
}
- (void) loadDataWithOperation
{
NSURL *dataURL = [NSURL URLWithString:@"http://icodeblog.com/samples/nsoperation/data.plist"];
NSArray *tmp_array = [NSArray arrayWithContentsOfURL:dataURL];
for(NSString *str in tmp_array) {
[self.array addObject:str];
}
[self.tableView reloadData];
[UIApplicationsharedApplication].networkActivityIndicatorVisible = NO;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment