I’m loading XML and it “pauses” my application while the data is loading. Is there some way to do all the loading in a thread other than the main thread? I’ve tried syncrhronous loading thinking that would do the trick, but no dice.
so far:
NSString *url = @"url for all my xml";
NSError *error = nil;
NSURLResponse *response = nil;
NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
NSData *data = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&error];
You’re calling
sendSynchronousRequest:returningResponse:error:, from Apple’s docs:If you make any of the calls to the asynchronous methods, like
sendAsynchronousRequest:queue:completionHandler:, it won’t block your main thread. And should allow you to do UI updates whilst loading your XML in the background.