Search code examples
objective-cnsurlconnectionnsurlconnectiondelegate

NSURLConnection Timeout Not Wotking


Im trying to download a file using NSURLConnection I've prepared the url request, delegate methods, etc. I also set the timeout to 15.0 and I'm triggering the download on main thread with a code like this:

NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
[connection start];

This code works just fine but in case of no response from server there is no callback to delegate method for errors.

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error

Regards


Solution

  • Check out this documentation, this will help you find a better way: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html#//apple_ref/doc/uid/20001836-BAJEAIEE