Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 78 lines (49 sloc) 2.766 kB
4248f17 @soffes Initial commit
authored
1 # SSKeychain
2
62adde0 @soffes Require ARC
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.
9727bb6 @soffes Switched to simpler implementation
authored
4
99579d5 @soffes Clean up
authored
5 ## Adding to Your Project
9727bb6 @soffes Switched to simpler implementation
authored
6
fb400dd @soffes Update Readme.markdown
authored
7 Simply add the following to your Podfile if you're using CocoaPods:
8
9 ``` ruby
10 pod 'SSKeychain'
11 ```
12
21636c8 @jpsim Changed Xcode project to create frameworks instead of example iOS & O…
jpsim authored
13 or Cartfile if you're using Carthage:
14
15 ```
16 github "soffes/SSKeychain"
17 ```
18
fb400dd @soffes Update Readme.markdown
authored
19 To manually add to your project:
20
f740f98 @soffes Updated readme and renamed `accounts` to `allAccounts`
authored
21 1. Add `Security.framework` to your target
a2b7b14 @calebd Update read me.
calebd authored
22 2. Add `SSKeychain.h`, `SSKeychain.m`, `SSKeychainQuery.h`, and `SSKeychainQuery.m` to your project.
9727bb6 @soffes Switched to simpler implementation
authored
23
62adde0 @soffes Require ARC
authored
24 SSKeychain requires ARC.
ca7ebbc @soffes Version 0.1.3
authored
25
ef6d380 @soffes Add 10.6 note to readme
authored
26 Note: Currently SSKeychain does not support Mac OS 10.6.
27
99579d5 @soffes Clean up
authored
28 ## Working with the Keychain
9727bb6 @soffes Switched to simpler implementation
authored
29
30 SSKeychain has the following class methods for working with the system keychain:
31
7e1a45a @soffes Updated readme and comments
authored
32 ```objective-c
f740f98 @soffes Updated readme and renamed `accounts` to `allAccounts`
authored
33 + (NSArray *)allAccounts;
34 + (NSArray *)accountsForService:(NSString *)serviceName;
35 + (NSString *)passwordForService:(NSString *)serviceName account:(NSString *)account;
36 + (BOOL)deletePasswordForService:(NSString *)serviceName account:(NSString *)account;
37 + (BOOL)setPassword:(NSString *)password forService:(NSString *)serviceName account:(NSString *)account;
7e1a45a @soffes Updated readme and comments
authored
38 ```
9727bb6 @soffes Switched to simpler implementation
authored
39
a682ab7 @soffes Update Readme.markdown
authored
40 Easy as that. (See [SSKeychain.h](https://github.com/soffes/sskeychain/blob/master/SSKeychain/SSKeychain.h) and [SSKeychainQuery.h](https://github.com/soffes/sskeychain/blob/master/SSKeychain/SSKeychainQuery.h) for all of the methods.)
114d3d6 @soffes Updated readme
authored
41
752c8d7 @soffes Version 0.1.2
authored
42 ## Documentation
43
eb6bb0c @hashier How to build own docset
hashier authored
44 ### Use prepared documentation
45
166fac0 @soffes Update Readme.markdown
authored
46 Read the [online documentation](http://cocoadocs.org/docsets/SSKeychain).
eb6bb0c @hashier How to build own docset
hashier authored
47
114d3d6 @soffes Updated readme
authored
48 ## Debugging
49
99579d5 @soffes Clean up
authored
50 If your saving to the keychain fails, use the NSError object to handle it. You can invoke `[error code]` to get the numeric error code. A few values are defined in SSKeychain.h, and the rest in SecBase.h.
114d3d6 @soffes Updated readme
authored
51
7e1a45a @soffes Updated readme and comments
authored
52 ```objective-c
53 NSError *error = nil;
99579d5 @soffes Clean up
authored
54 SSKeychainQuery *query = [[SSKeychainQuery alloc] init];
55 query.service = @"MyService";
56 query.account = @"soffes";
57 [query fetch:&error];
7e1a45a @soffes Updated readme and comments
authored
58
99579d5 @soffes Clean up
authored
59 if ([error code] == errSecItemNotFound) {
7e1a45a @soffes Updated readme and comments
authored
60 NSLog(@"Password not found");
fc5b200 @paulmelnikow Call SecCopyErrorMessageString to provide a description for NSError o…
paulmelnikow authored
61 } else if (error != nil) {
99579d5 @soffes Clean up
authored
62 NSLog(@"Some other error occurred: %@", [error localizedDescription]);
7e1a45a @soffes Updated readme and comments
authored
63 }
64 ```
114d3d6 @soffes Updated readme
authored
65
99579d5 @soffes Clean up
authored
66 Obviously, you should do something more sophisticated. You can just call `[error localizedDescription]` if all you need is the error message.
67
68 ## Disclaimer
69
70 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.
71
72
73 ## Thanks
74
75 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).
76
77 A huge thanks to [Caleb Davenport](https://github.com/calebd) for leading the way on version 1.0 of SSKeychain.
Something went wrong with that request. Please try again.