I have this code:
[NSURLConnection sendAsynchronousRequest:urlRequest queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
{
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
if ( error != nil )
{
// Display a message to the screen.
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"There was a server error getting your business plan. We use a remote server to backup your work."
message:@"Please make sure your phone is connected to the Internet. If the problem persists, please let us know about this."
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[message show];
but it executes when a NSUrlConnection returns from the server. It creates a crash on rare occasions. Is it possible? It seems like such a harmless piece of code.
Thanks!
Is the NSURLConnection returning a result on some odd thread? I don’t know, but I suspect that UIAlertView is only meant to work on the UI thread, since it starts with UI.
Sorry, haven’t compiled this, there’s probably a typo in there somewhere.