Created
January 23, 2015 23:10
-
-
Save mattrubin/dd2b43c0ad3f8acfc09b to your computer and use it in GitHub Desktop.
Get every password in the keychain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (NSArray *)allKeychainItems | |
{ | |
NSDictionary *queryDict = @{(__bridge id)kSecClass: (__bridge id)kSecClassGenericPassword, | |
(__bridge id)kSecMatchLimit: (__bridge id)kSecMatchLimitAll, | |
(__bridge id)kSecReturnPersistentRef: (id)kCFBooleanTrue, | |
(__bridge id)kSecReturnAttributes: (id)kCFBooleanTrue, | |
(__bridge id)kSecReturnData: (id)kCFBooleanTrue | |
}; | |
CFTypeRef result = NULL; | |
OSStatus resultCode = SecItemCopyMatching((__bridge CFDictionaryRef)(queryDict), | |
&result); | |
if (resultCode != errSecSuccess) { | |
NSLog(@"Keychain result code: %d", (int)resultCode); | |
} | |
return (resultCode == errSecSuccess) ? (__bridge NSArray *)(result) : nil; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment