Dead simple keychain wrapper for iOS.
Objective-C Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
ACSimpleKeychain
KeychainExample.xcodeproj
KeychainExample
KeychainExampleTests
.gitignore
ACSimpleKeychain.podspec
LICENSE
README.mdown

README.mdown

Dead simple keychain wrapper for iOS.

Initialization: ACSimpleKeychain *keychain = [ACSimpleKeychain defaultKeychain];

Storing credentials: // Save credentials for user1 if ([keychain storeUsername:@"user1" password:nil identifier:@"account1" forService:@"twitter"]) { NSLog(@"SAVED credentials for username 'user1' credentials identifier 'account1'"); }

// Save credentials for user2
if ([keychain storeUsername:@"user2" password:@"password" identifier:@"account2" forService:@"twitter"]) {
    NSLog(@"SAVED credentials for username 'user2' credentials identifier 'account2'");
}

// Replace user2 with user3
if ([keychain storeUsername:@"user3" password:@"password" identifier:@"account2" forService:@"twitter"]) {
    NSLog(@"CHANGED credentials for credentials identifier 'account2'");
}    

Retrieving credentials: // Request all credentials for service 'twitter' (max 99 entries) NSArray *all = [keychain allCredentialsForService:@"twitter" limit:99]; NSLog(@"All credentials for service 'twitter %@", all);

// Request credentials for account with username 'user1'
NSDictionary *credentials = [keychain credentialsForUsername:@"user1" service:@"twitter"];
NSLog(@"CREDENTIALS: service: %@, identifier: %@, username: %@, password: %@",
    [credentials valueForKey:ACKeychainService],
    [credentials valueForKey:ACKeychainIdentifier],
    [credentials valueForKey:ACKeychainUsername],
    [credentials valueForKey:ACKeychainPassword]);

// Request credentials for account with identifier 'account2'
credentials = [keychain credentialsForIdentifier:@"account2" service:@"twitter"];
NSLog(@"CREDENTIALS: service: %@, identifier: %@, username: %@, password: %@",
    [credentials valueForKey:ACKeychainService],
    [credentials valueForKey:ACKeychainIdentifier],
    [credentials valueForKey:ACKeychainUsername],
    [credentials valueForKey:ACKeychainPassword]);

Removing credentials: // Delete credentials for account with identifier 'account1' if ([keychain deleteCredentialsForIdentifier:@"account1" service:@"twitter"]) { NSLog(@"DELETED credentials for 'account1'"); }

// Request credentials for account with username 'user3'
if ([keychain deleteCredentialsForUsername:@"user3" service:@"twitter"]) {
    NSLog(@"DELETED credentials for 'user3'");
}

// Delete all account for service MobileMe
if ([keychain deleteAllCredentialsForService:@"MobileMe"]) {
    NSLog(@"DELTED all credentials for service 'MobileMe'");
}