Created
June 4, 2012 16:19
-
-
Save anthonycvella/2869343 to your computer and use it in GitHub Desktop.
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
- (IBAction)JSONLoader:(id)sender | |
{ | |
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; | |
[spinner startAnimating]; | |
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:spinner]; | |
[self refreshServers]; | |
self.navigationItem.leftBarButtonItem = sender; | |
} | |
- (void)refreshServers | |
{ | |
dispatch_queue_t parsingQueue = dispatch_queue_create("JSONData", NULL);; | |
dispatch_async(parsingQueue, ^{ | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://old.hungercraft.net/serverlist.php"]]; | |
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | |
NSArray *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; | |
_dataJSON = [json copy]; | |
[_tableView reloadData]; | |
}]; | |
}); | |
}); | |
dispatch_release(parsingQueue); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment