I'm trying to remove credentials from storage when an account is deleted from my app. Here's the code I'm us开发者_运维百科ing:
NSDictionary *dict = [[NSURLCredentialStorage sharedCredentialStorage] allCredentials];
NSDictionary *dictCopy = [dict copy];
for(NSURLProtectionSpace *key in [dictCopy keyEnumerator])
{
NSDictionary *value = [dict objectForKey:key];
NSURLCredential *cred = [value objectForKey:accountLogin];
if(cred)
[[NSURLCredentialStorage sharedCredentialStorage] removeCredential:cred forProtectionSpace:key];
}
NSLog(@"%@",[[NSURLCredentialStorage sharedCredentialStorage] allCredentials]);
The remove part gets called for all of the right keys and values but after the method completes, all of the credentials are still intact. How is that possible?
I've also tried setting new credentials but it seems like they aren't getting recognized either
精彩评论