Disabling ARC is a short-sighted answer. I have included an ARC-compatible version of KeychainWrapper below.
I got it from this project .
Note. Experts on this issue (see comments below) believe that this is a more efficient implementation: https://gist.github.com/1170641
Also note that KeyChain credentials are saved after the application is uninstalled. If you use this to authenticate token , you can use NSUserDefaults instead. See this post for more details.
//File: KeychainWrapper.h #import <UIKit/UIKit.h> @interface KeychainWrapper : NSObject {} + (NSString *) getPasswordForUsername: (NSString *) username andServiceName: (NSString *) serviceName error: (NSError **) error; + (BOOL) storeUsername: (NSString *) username andPassword: (NSString *) password forServiceName: (NSString *) serviceName updateExisting: (BOOL) updateExisting error: (NSError **) error; + (BOOL) deleteItemForUsername: (NSString *) username andServiceName: (NSString *) serviceName error: (NSError **) error; @end
and implementation:
//File: KeychainWrapper.m #import "KeychainWrapper.h" #import <Security/Security.h> static NSString *KeychainWrapperErrorDomain = @"KeychainWrapperErrorDomain";
source share