Skip to content
Browse files

Merge pull request #15 from noa--/pullreq2

Fix bug where items sometimes aren't deleted on Mac OS
  • Loading branch information...
2 parents e3736a3 + f254692 commit 7e767b4b1b1f532d8091d3dbc17a6fb61028b428 @soffes committed Jan 26, 2013
Showing with 9 additions and 2 deletions.
  1. +9 −2 SSKeychain.m
View
11 SSKeychain.m
@@ -146,11 +146,18 @@ + (BOOL)deletePasswordForService:(NSString *)service account:(NSString *)account
OSStatus status = SSKeychainErrorBadArguments;
if (service && account) {
NSMutableDictionary *query = [self _queryForService:service account:account];
+ CFTypeRef result;
#if __has_feature(objc_arc)
- status = SecItemDelete((__bridge CFDictionaryRef)query);
+ [query setObject:(__bridge id)kCFBooleanTrue forKey:(__bridge id)kSecReturnRef];
+ status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &result);
#else
- status = SecItemDelete((CFDictionaryRef)query);
+ [query setObject:(id)kCFBooleanTrue forKey:(id)kSecReturnRef];
+ status = SecItemCopyMatching((CFDictionaryRef)query, &result);
#endif
+ if (errSecSuccess == status) {
+ status = SecKeychainItemDelete((SecKeychainItemRef) result);
+ CFRelease(result);
+ }
}
if (status != noErr && error != NULL) {
*error = [NSError errorWithDomain:kSSKeychainErrorDomain code:status userInfo:nil];

0 comments on commit 7e767b4

Please sign in to comment.
Something went wrong with that request. Please try again.