Skip to content

Instantly share code, notes, and snippets.

@justin
Created April 9, 2012 00:56
Show Gist options
  • Save justin/2340617 to your computer and use it in GitHub Desktop.
Save justin/2340617 to your computer and use it in GitHub Desktop.
SGKeyboard Example
// 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