【发布时间】:2012-03-28 09:25:15
【问题描述】:
我在登录时在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 秒后重新登录,它就会起作用。
提前谢谢.. 阿杰
【问题讨论】:
-
您找到解决方案了吗?我刚开始考虑自己添加注销功能。