セキュリティで保護されたHTTPサイトにアクセスするときに書き込まれるNSURLCredentialを削除しようとしています。NSURLCredentialを永久に削除しますか?
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60];
は、キャッシュされたデータを再ロードしないと、私はこの方法実装しました::
- (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse {
return nil;
}
私は次回実行時に動作し、NSURLCredentialStorage
からNSURLCredential
を削除しますが、私はそれを指定していていても、以下のコードアプリケーションdeleteStoredCredentialが "loginSiteName.com"の新しい認証情報を検索して削除します。私の質問は、私が何かを逃している、私はクリアする必要がある他にどこにありますか、資格情報をiPhoneにキャッシュすることができますか?
-(void)deleteStoredCredential {
NSURLCredentialStorage *sharedCredentialStorage = [NSURLCredentialStorage sharedCredentialStorage];
NSDictionary *DICT_allProtectionSpaces = [sharedCredentialStorage allCredentials];
// DICT KEY = NSURLProtectionSpace
// DICT VALUE = NSDictionary
for(NSURLProtectionSpace *thisProtectionSpace in DICT_allProtectionSpaces) {
if([[thisProtectionSpace host] isEqualToString:@"loginSiteName.com"]) {
NSDictionary *DICT_allCredentials = [sharedCredentialStorage credentialsForProtectionSpace:thisProtectionSpace];
// DICT KEY = NSString (i.e. username)
// DICT VALUE = NSURLCredential
for(NSString *thisUserName in DICT_allCredentials) {
NSURLCredential *credentialToDelete = [DICT_allCredentials valueForKey:thisUserName];
NSLog(@"REMOVE UID: %@ WITH PWD: %@", [credentialToDelete user], [credentialToDelete password]);
[sharedCredentialStorage removeCredential:credentialToDelete forProtectionSpace:thisProtectionSpace];
}
}
}
}
あなたはおそらく1は、キーチェーンからその資格を削除することができる方法を知っています助けるために
のおかげ? – doge
私も同じ問題を抱えています。 NSURLCredentialPersistenceNoneを資格情報に設定しました。何かがまだキャッシュされています。 – lostintranslation