Skip to content

Instantly share code, notes, and snippets.

@zwang
Created August 27, 2012 04:23
Show Gist options
  • Save zwang/3485526 to your computer and use it in GitHub Desktop.
Save zwang/3485526 to your computer and use it in GitHub Desktop.
Use Apple's KeychainItemWrapper in ARC project from @ErikEvenson
Thanks to ErikEvenson https://github.com/ErikEvenson
I did three things to use Apple's current sample code in my ARC projects:
1) Set -fno-objc-arc as a compiler flag on KeychainItemWrapper.m under Build Phases, Compile Sources.
2) Use __bridge_transfer in the call to the wrapper: NSString *password = [wrapper objectForKey:(__bridge_transfer id)kSecValueData];
3) Add an autorelease to line 196 of Apple's code to plug Apple's memory leak: self.keychainItemData = [[[NSMutableDictionary alloc] init] autorelease];
Another solution which rewrites the code in ARC can be found here
https://gist.github.com/1170641
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment