#GSKeychain – a simple Objective-C wrapper around the iOS keychain
This project provides a simple, NSUserDefaults
-style interface over the
iOS keychain.
This is currently work in progress.
#Sample usage
// Store a secret
[[GSKeychain systemKeychain] setSecret:@"t0ps3kr1t" forKey:@"myAccessToken"];
// Fetch a secret
NSString *secret = [[GSKeychain systemKeychain] secretForKey:@"myAccessToken"];
// Delete a secret
[[GSKeychain systemKeychain] removeSecretForKey:@"myAccessToken"];
#Adding to your project
##Drag and drop
- Drag
GSKeychain.h
andGSKeychain.m
into your project - Add Security.framework to Link Binary With Libraries in your target settings in Xcode
import "GSKeychain.h"
where appropriate
GSKeychain uses ARC. If your project doesn't use ARC you could enable it for these files, or use GSArchive as a static library instead.
##As a static library
- Download the project and build it
- Drag libGSKeychain.a and GSKeychain.h into your project
- Add Security.framework to Link Binary With Libraries in your target settings in Xcode
import "GSKeychain.h"
where appropriate
#Credits
Work inspired by reading Peeking Inside App Bundles by Nick Arnott.
#License
This work is licensed under a Creative Commons Attribution 3.0 Unported License.
You're free to use this code in any project, including commercial. Please include the following text somewhere suitable, e.g. your app's About screen:
Uses GSKeychain by Simon Whitaker