Created
July 15, 2011 06:01
-
-
Save marshluca/1084164 to your computer and use it in GitHub Desktop.
NSOperationQueue,NSInvocationOperation
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
- (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