我在登录时使用NSURLCredentialPersistenceForSession
的didReceiveAuthenticationChallenge
的NSURLConnection
委托方法。 现在,当我退出,并使用此代码清除存储..在请求时使用NSURLCredentialPersistenceForSession,然后在注销时清除凭证仍然保留证书
NSURLCredentialStorage *credentialStorage = [NSURLCredentialStorage sharedCredentialStorage];
NSDictionary *credentialsDicationary = [credentialStorage allCredentials];
NSLog(@"credentialsDicationary..%@",[credentialsDicationary description]);
for (NSURLProtectionSpace *space in [credentialsDicationary allKeys]) {
NSDictionary *spaceDictionary = [credentialsDicationary objectForKey:space];
NSLog(@"spaceDictionary..%@",[spaceDictionary description]);
for (id userName in [spaceDictionary allKeys]) {
NSURLCredential *credential = [spaceDictionary objectForKey:userName];
[credentialStorage removeCredential:credential forProtectionSpace:space];
}
}
但是,当我突然再次登录后正好注销登录情况与错误的凭据。请让mw知道如何清除缓存。如果我在5秒钟之后重新登录,它就可以工作。
在此先感谢.. AJ
你得到一个解决方案吗?我刚开始考虑自己添加注销功能。 – DBD 2012-08-31 14:35:40