开发者

Can't remove NSURLCredentials from storage

开发者 https://www.devze.com 2023-03-30 14:58 出处:网络
I\'m trying to remove credentials from storage when an account is deleted from my app.Here\'s the code I\'m us开发者_运维百科ing:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消