我们的 iPhone 模拟器出现问题,是由于使用此行引起的:
Foo = [NSURLCredential CredentialWithUser:foo
password:bar persistance:NSURLCredentialPersistencePermanent];
问题是在向挑战提供凭据时产生的
-(NSURLConnection *)connection
didReceiveAuthenticationChallenge(NSURLAuthenticationChallenge *)challenge
{
[[challenge sender]useCredential:Foo forAuthenticationChallenge:challenge]
}
现在,当我们运行应用程序时,我们再也不会遇到身份验证挑战,这很奇怪,即使我们将凭据更改为
Foo = [NSURLCredential CredentialWithUser:foo
password:bar persistance:NSURLCredentialPersistenceForSession];
or even
Foo = [NSURLCredential CredentialWithUser:foo
password:bar persistance:NSURLCredentialPersistenceNone];
总结一下:
通过使用 credentialpersistencepermanent,凭证会以某种方式保存在某个地方,并自动用于访问我们需要验证自己的任何地方。
因此,出于测试目的,我们真的很想删除这个持久的...凭证。
有人有什么想法吗? :)
最佳答案
您是否尝试过重置模拟器?它位于模拟器菜单中。
关于ios - NSURLCredential 是永久的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6226439/