Created
April 9, 2012 00:56
-
-
Save justin/2340617 to your computer and use it in GitHub Desktop.
SGKeyboard Example
This file contains hidden or 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
// Store a password | |
NSError *storePasswordError = nil; | |
BOOL passwordSuccessfullyCreated = [SGKeychain setPassword:@"testpassword" username:@"justin" serviceName:@"Twitter" updateExisting:NO error:&storePasswordError]; | |
if (passwordSuccessfullyCreated == YES) | |
{ | |
NSLog(@"Password successfully created"); | |
} | |
else | |
{ | |
NSLog(@"Password failed to be created with error: %@", storePasswordError); | |
} | |
// Fetch the password | |
NSError *fetchPasswordError = nil; | |
NSString *password = [SGKeychain passwordForUsername:@"justin" serviceName:@"Twitter" error:&fetchPasswordError]; | |
if (password != nil) | |
{ | |
NSLog(@"Fetched password = %@", password); | |
} | |
else | |
{ | |
NSLog(@"Error fetching password = %@", fetchPasswordError); | |
} | |
// Delete the password | |
NSError *deletePasswordError = nil; | |
BOOL passwordSuccessfullyDeleted = [SGKeychain deletePasswordForUsername:@"justin" serviceName:@"Twitter" error:&deletePasswordError]; | |
if (passwordSuccessfullyDeleted == YES) | |
{ | |
NSLog(@"Password successfully deleted"); | |
} | |
else | |
{ | |
NSLog(@"Failed to delete password: %@", deletePasswordError); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment