I am making an asynchronous url request with a new iOS 5 method: sendAsynchronousRequest: queue: completeHandler :. This uses a block to handle the response, but the NSURLConnectionDelegate delegate methods are not called? I don’t see a way to set a delegate for the NSUrlConnection class in this instance?
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
NSLog(@"HTTP response code: %i", httpResponse.statusCode);
if (error != nil) {
NSLog(@"There was error with the synchronous request: %@", error.description);
}
}];
The reason I need delegate methods is because one of my calls gets a 401 response, which iOS handles differently - defer authentication to delegate methods. When the response 401 is returned - httpResponse.statusCode is just "0".
iOS 401 -? , , continueWithoutCredentialForAuthenticationChallenge: delegate, .
!