NSURL *httpsURL = [NSURL URLWithString:@"https://example.com"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:httpsURL cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:5.0f];
self.connection = [NSURLConnection connectionWithRequest:request delegate:self];
[self.connection start];
while(something) {
// some code
}
In the above code, the delegates (ex: willSendRequestForAuthenticationChallenge
) are not executing until the while
loop is completed. What is the reason for this behaviour and how to overcome this issue? I want the delegates to be executed in the background. How can I achieve it?
Thanks in advance.