Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 61 lines (38 sloc) 2.628 kB
4248f17 @soffes Initial commit
soffes authored
1 # SSKeychain
2
ca7ebbc @soffes Version 0.1.3
soffes authored
3 SSKeychain is a simple wrapper for accessing accounts, getting passwords, setting passwords, and deleting passwords using the system Keychain on Mac OS X and iOS. SSKeychain works in ARC and non-ARC projects.
9727bb6 @soffes Switched to simpler implementation
soffes authored
4
5 This was originally inspired by EMKeychain and SDKeychain (both of which are now gone). Thanks to the authors. SSKeychain has since switched to a simpler implementation that was abstracted from [SSToolkit](http://sstoolk.it).
6
7 ## Adding to your project
8
f740f98 @soffes Updated readme and renamed `accounts` to `allAccounts`
soffes authored
9 1. Add `Security.framework` to your target
10 2. Add `SSKeychain.h` and `SSKeychain.m` to your project.
9727bb6 @soffes Switched to simpler implementation
soffes authored
11
ca7ebbc @soffes Version 0.1.3
soffes authored
12 You don't need to do anything regarding ARC. SSKeychain will detect if you're not using ARC and add the required memory management code.
13
ef6d380 @soffes Add 10.6 note to readme
soffes authored
14 Note: Currently SSKeychain does not support Mac OS 10.6.
15
9727bb6 @soffes Switched to simpler implementation
soffes authored
16 ## Working with the keychain
17
18 SSKeychain has the following class methods for working with the system keychain:
19
7e1a45a @soffes Updated readme and comments
soffes authored
20 ```objective-c
f740f98 @soffes Updated readme and renamed `accounts` to `allAccounts`
soffes authored
21 + (NSArray *)allAccounts;
22 + (NSArray *)accountsForService:(NSString *)serviceName;
23 + (NSString *)passwordForService:(NSString *)serviceName account:(NSString *)account;
24 + (BOOL)deletePasswordForService:(NSString *)serviceName account:(NSString *)account;
25 + (BOOL)setPassword:(NSString *)password forService:(NSString *)serviceName account:(NSString *)account;
7e1a45a @soffes Updated readme and comments
soffes authored
26 ```
9727bb6 @soffes Switched to simpler implementation
soffes authored
27
f740f98 @soffes Updated readme and renamed `accounts` to `allAccounts`
soffes authored
28 Easy as that. (See [SSKeychain.h](https://github.com/samsoffes/sskeychain/blob/master/SSKeychain.h) for all of the methods.)
114d3d6 @soffes Updated readme
soffes authored
29
752c8d7 @soffes Version 0.1.2
soffes authored
30 ## Documentation
31
32 Install the documentation into Xcode with the following steps:
33
34 1. Open Xcode Preferences
35 2. Choose Downloads
36 3. Choose the Documentation tab
62c6442 @soffes Updated readme
soffes authored
37 4. Click the plus button in the bottom right and enter the following URL:
752c8d7 @soffes Version 0.1.2
soffes authored
38
39 http://docs.samsoff.es/com.samsoffes.sskeychain.atom
40
ded478a @soffes Updated readme
soffes authored
41 5. Click Install next the new row reading "SSKeychain Documentation". (If you don't see it and didn't get an error, try restarting Xcode.)
62c6442 @soffes Updated readme
soffes authored
42
752c8d7 @soffes Version 0.1.2
soffes authored
43 Be sure you have the docset selected in the organizer to see results for SSKeychain.
44
45 You can also **read the [SSKeychain Documentation](http://docs.samsoff.es/SSKeychain/Classes/SSKeychain.html) online.**
46
114d3d6 @soffes Updated readme
soffes authored
47 ## Debugging
48
49 If you saving to the keychain fails, you use the error codes provided in SSKeychain.h. Here's an example:
50
7e1a45a @soffes Updated readme and comments
soffes authored
51 ```objective-c
52 NSError *error = nil;
53 NSString *password = [SSKeychain passwordForService:@"MyService" account:@"samsoffes" error:&error];
54
55 if ([error code] == SSKeychainErrorNotFound) {
56 NSLog(@"Password not found");
57 }
58 ```
114d3d6 @soffes Updated readme
soffes authored
59
60 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.
Something went wrong with that request. Please try again.