Hi,
I'm trying to create an iPhone app that pulls data from a web services as a JSON string, however when I do this, I sometimes get this error:
I understand what the error is telling me (I think), but don't know how to fix it!
Here's my code I'm using to get the JSON data, which runs on the press of a button after the user fills out some required info:
Any advice?
Cheers!
I'm trying to create an iPhone app that pulls data from a web services as a JSON string, however when I do this, I sometimes get this error:
"Obtaining the web lock from a thread other than the main thread or the web thread. UIKit should not be called from a secondary thread."
I understand what the error is telling me (I think), but don't know how to fix it!
Here's my code I'm using to get the JSON data, which runs on the press of a button after the user fills out some required info:
Code:
if(self.textbox.text){
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^{
NSError *error = nil;
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"URL-TO-WEB-SERVICE"]];
NSString *json = [NSString stringWithContentsOfURL:url
encoding:NSASCIIStringEncoding
error:&error];
Any advice?
Cheers!