Skip to content

Instantly share code, notes, and snippets.

View ndfred's full-sized avatar

Frédéric Sagnes ndfred

  • Facebook
  • London, UK
View GitHub Profile
@ndfred
ndfred / gist:775896
Created January 12, 2011 08:53
Saving a login and a password to the iOS keychain
- (void)setCredentialsFromKeychain {
NSMutableDictionary *query = [NSMutableDictionary dictionary];
NSDictionary *result = nil;
[query setObject:(id)kSecClassGenericPassword forKey:(id)kSecClass];
[query setObject:kLCSessionManagerKeychainSubscriptionServiceKey forKey:(id)kSecAttrService];
[query setObject:(id)kCFBooleanTrue forKey:(id)kSecReturnAttributes];
[query setObject:(id)kCFBooleanTrue forKey:(id)kSecReturnData];
if (SecItemCopyMatching((CFDictionaryRef)query, (CFTypeRef *)&result) == errSecSuccess) {