I am using the below code for authentication of the user with the remote server.If I am giving correct username and password, there is no issue because authentication is hap
You need to check the error count and cancel the authentication challenge appropriately:
if ([challenge previousFailureCount]) {
[[challenge sender] cancelAuthenticationChallenge:challenge];
} else {
[[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
}
Try this.
- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
if ([challenge previousFailureCount] > 0) {
// do something may be alert message
}
else
{
NSURLCredential *credential = [NSURLCredential credentialWithUser:@"username"
password:@"password"
persistence:NSURLCredentialPersistenceForSession];
[[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
}
}