6

私はNSURLCredentialStorage、特定の保護空間のために保存された資格情報を使用する iOS アプリケーションの作成に取り組んできました。proposedCredential保存された資格情報を取得するために使用するところまで来ました。

私の問題は、それが返されていることであり、実際に何が行われ、なぜ私がそうすべきだと思うものが返されないのかnullについて、良い説明が見つからないようです。proposedCredential

これは私がやっていることです:

最初に を定義しNSURLProtectionSpace、資格情報を指定して に保存しますNSURLCredentialStorage。参照する前にこれが行われているproposedCredentialこと、および渡す資格情報が正しいことを確認しました。

NSURLProtectionSpace *protectionSpaceOne = [[NSURLProtectionSpace alloc] 
                                           initWithHost:xyz 
                                              port: 80 
                                              protocol:NSURLProtectionSpaceHTTP 
                                              realm:nil 
                                              authenticationMethod:NSURLAuthenticationMethodDefault];

  //credential is initiated elsewhere.
[[NSURLCredentialStorage sharedCredentialStorage] setDefaultCredential:credential forProtectionSpace:protectionSpaceOne]; 

-(void)connection:(NSURLConnection *)connection didRecieveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge{
   //Has the authentication failed before?
   if([challenge previousFailureCount]>0){
      //Why?
      NSError *error = [challenge error];
       //Here I respond to the failure count
       [[challenge sender]cancelAuthenticationCallenge:challenge];
   }

   NSURLCredential *proposedCredential = [challenge proposedCredential];

}

誰かがproposedCredential実際に何をしているのか、渡すべき資格情報があるかどうかを比較するために何を比較しているのか、コードに欠けている可能性があるものを教えてもらえますか?

参考までに、私はAppleのドキュメント、具体的にはthisthis、およびthisを読んでいます

すべての助けをいただければ幸いです。

4

0 に答える 0