I tried several ways to execute NSURLConnection while locking the screen, but none of this works.
I tried the following:
[self performSelectorInBackground:@selector(startConnection) withObject:nil];
I also tried:
dispatch_queue_t request_queue = dispatch_queue_create("com.app.download", NULL); dispatch_async(request_queue, ^{ [self startConnection]; });
in startConnection:
- (void)startConnection{ ... some URL processing responseData_ = [[NSMutableData alloc] init]; connection_ = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self]; }
NSURLConnection delegate methods are not called in this way. What is the real code to make it work? Thanks!
A small update that may help :
It only calls this delegate method:
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
with the message:
Could not find a server with the specified host name.
I am very sure that my Wi-Fi is connected, still not sure why it is called: (
source share