Thursday, July 8, 2010

NSURLErrorDomain error -1012

So have you run across this one when trying to issue some url requests? What it means is there was an authentication error - NSURLErrorUserCancelledAuthentication. Okay, so what does that mean? You likely are trying to issue a synchronous http request and not passing proper authentication, or you've messed up your auth in some other manner. It's a lot easier to handle authentication when using asynchronous calls and responding to the auth challenge:

-(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
    if ([challenge previousFailureCount] == 0) {
        NSURLCredential *newCredential;
        newCredential=[NSURLCredential credentialWithUser:@"username"
        [[challenge sender] useCredential:newCredential
    } else {
        [[challenge sender] cancelAuthenticationChallenge:challenge];

1 comment:

  1. Any insight to what this error means? The operation couldn’t be completed. (NSURLErrorDomain error -1015). Does anyone have a list of what these error code numbers are?