Skip to content

Instantly share code, notes, and snippets.

@anthonycvella
Created June 4, 2012 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonycvella/2869343 to your computer and use it in GitHub Desktop.
Save anthonycvella/2869343 to your computer and use it in GitHub Desktop.
- (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