NGBAccountStore is a simple drop-in class for storing complete account objects encrypted in the system keychain. iCloud sync is supported, too.
NGBAccountStore works only on iOS7 as it uses the built in base64 decoder. But I'm happy to accept pull requests adding backwards compability.
CocoaPods is the recommended way to add NGBAccountStore to your project.
- Add a pod entry for MBProgressHUD to your Podfile
pod 'NGBAccountStore', '~> 0.1.0'
- Install the pod(s) by running
pod install
.
Alternatively you can directly add the source files to your project.
- Download the latest code version or add the repository as a git submodule to your git-tracked project.
- Open your project in Xcode, then drag and drop all classes in the AccountStore folder onto your project (use the "Product Navigator view"). Make sure to select Copy items when asked if you extracted the code archive outside of your project.
Just instantiate an instance of NGBAccountStore or use the provided Singleton, then add your accounts. You can use the provided convenience class NGBAccount or roll your own account class by implementing the NGBManagedAccount protocol on your account.
Password saving is decoupled from the account object as the password should not stay in memory for security reasons.
NSArray* accounts = [NGBAccountStore defaultStore].accounts;
NGBAccount* account = [[NGBAccount alloc] init];
account.identifier = @"thisismyid";
account.username = "John Doe";
[[NGBAccountStore defaultStore] addAccount: account];
[[NGBAccountStore defaultStore] setPassword:@"secret!"" forAccount:account];
NGBAccount* account = [NGBAccountStore defaultStore].accounts.firstObject;
NSString* password = [[NGBAccountStore defaultStore] passwordForAccount:account];
// or use the convenience method:
password = account.password;
This code is distributed under the terms and conditions of the MIT license.
Have a new idea or found a bug? Please support this project by contributing pull requests.
First open an issue and state that you're working on something so there is no doubled work. Then submit your pull request.
- All public methods need to be documented with appledoc syntax.
- If you provide additional functionality, add a unit test.
- If you fix a bug, please add a unit test so the bug will not happen again.