Advertisement
Guest User

Untitled

a guest
Jan 27th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. -(void)connection:(NSURLConnection *)connectionParam didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
  2. if([challenge previousFailureCount] == 0) {
  3. NSURLCredential *newCredential=[NSURLCredential credentialWithUser:@"your username" password:@"your password" persistence:NSURLCredentialPersistenceNone];
  4. [[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge];
  5. } else {
  6. [[challenge sender] cancelAuthenticationChallenge:challenge];
  7. NSError* error = [NSError errorWithDomain:@"RequestResultHandler" code:403 userInfo: [NSDictionary dictionaryWithObjectsAndKeys: @"Could not authenticate this request", NSLocalizedDescriptionKey,nil]];
  8. [self handleError:error];
  9. }
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement