Skip to content
This repository has been archived by the owner on Aug 24, 2019. It is now read-only.

Commit

Permalink
Updated readme and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
soffes committed Jul 25, 2011
1 parent 7ea080c commit 7e1a45a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
28 changes: 16 additions & 12 deletions Readme.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,30 @@ This was originally inspired by EMKeychain and SDKeychain (both of which are now

SSKeychain has the following class methods for working with the system keychain:

+ (NSString *)passwordForService:(NSString *)service account:(NSString *)account;
+ (NSString *)passwordForService:(NSString *)service account:(NSString *)account error:(NSError **)error;
```objective-c
+ (NSString *)passwordForService:(NSString *)service account:(NSString *)account;
+ (NSString *)passwordForService:(NSString *)service account:(NSString *)account error:(NSError **)error;

+ (BOOL)deletePasswordForService:(NSString *)service account:(NSString *)account;
+ (BOOL)deletePasswordForService:(NSString *)service account:(NSString *)account error:(NSError **)error;
+ (BOOL)deletePasswordForService:(NSString *)service account:(NSString *)account;
+ (BOOL)deletePasswordForService:(NSString *)service account:(NSString *)account error:(NSError **)error;

+ (BOOL)setPassword:(NSString *)password forService:(NSString *)service account:(NSString *)account;
+ (BOOL)setPassword:(NSString *)password forService:(NSString *)service account:(NSString *)account error:(NSError **)error;
+ (BOOL)setPassword:(NSString *)password forService:(NSString *)service account:(NSString *)account;
+ (BOOL)setPassword:(NSString *)password forService:(NSString *)service account:(NSString *)account error:(NSError **)error;
```

Easy as that.

## Debugging

If you saving to the keychain fails, you use the error codes provided in SSKeychain.h. Here's an example:

NSError *error = nil;
NSString *password = [SSKeychain passwordForService:@"MyService" account:@"samsoffes" error:&error];

if ([error code] == SSKeychainErrorNotFound) {
NSLog(@"Password not found");
}
```objective-c
NSError *error = nil;
NSString *password = [SSKeychain passwordForService:@"MyService" account:@"samsoffes" error:&error];

if ([error code] == SSKeychainErrorNotFound) {
NSLog(@"Password not found");
}
```
Obviously, you should do something more sophisticated. Working with the keychain is pretty sucky. You should really check for errors and failures. This library doesn't make it any more stable, it just wraps up all of the annoying C APIs.
2 changes: 1 addition & 1 deletion SSKeychain.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SSToolkit
//
// Created by Sam Soffes on 5/19/10.
// Copyright 2009-2010 Sam Soffes. All rights reserved.
// Copyright 2009-2011 Sam Soffes. All rights reserved.
//

#import <Security/Security.h>
Expand Down
2 changes: 1 addition & 1 deletion SSKeychain.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SSToolkit
//
// Created by Sam Soffes on 5/19/10.
// Copyright 2009-2010 Sam Soffes. All rights reserved.
// Copyright 2009-2011 Sam Soffes. All rights reserved.
//

#import "SSKeychain.h"
Expand Down

0 comments on commit 7e1a45a

Please sign in to comment.