EXC_BAD_ACCESSを引き起こしdidReceiveAuthenticationChallenge
-
22-09-2019 - |
質問
ウェブサイトが認証を必要としない場合、それは「作成した資格」印刷後にEXC_BAD_ACCESS権と、そのエラーがない場合は、
は、私のコードは、罰金に動作します。私は何を解放していないよ、このコードは、ドキュメントから直接コピーされます - ?何が間違っているすべてのアイデア
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
if ([challenge previousFailureCount] == 0)
{
NSLog(@"received authentication challenge");
NSURLCredential *newCredential;
newCredential=[NSURLCredential credentialWithUser:@"root"
password:@"rootpassword"
persistence:NSURLCredentialPersistenceForSession];
NSLog(@"credential created");
[[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge];
NSLog(@"responded to authentication challenge");
}
else
{
NSLog(@"previous authentication failure");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Authentication Failure"
message:@"Website did not accept the username and password."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}
解決
それの何か判明し、その特定のサイトの認証方法をどうする - 。私は別のウェブサイトを持つにログインするWebサイトを交換し、コードが正常に動作します。
(私はそれはそれとは何かを持っていると仮定しているので、unRaidは、実際のWebサーバが、emhttpを使用していない、unRaidのステータスページから擦りデータにしようとしていました)
他のヒント
あなたがコントロールしていない唯一のものは[challenge sender]
の戻り値です。それが非nilのだということを確実にするためにその説明を印刷してみます。
所属していません StackOverflow