I'd like get username/password out of my keychain. for this I followed this guide:
Simple iPhone Keychain Access
But this part is not allowed with ARC:
NSData *result = nil;
OSStatus status = SecItemCopyMatching(
(CFDictionaryRef)searchDictionary,
(CFTypeRef *)&result);
What can I do?
ARC only manages Objective-C types. If you cast to Core Foundation types you have to tell ARC who owns the variable by using __bridge
, __bridge_retained
or __bridge_transfer
.
Here's Apple's official documentation on toll-free bridging under ARC, or see this blog post (scroll down to Toll-Free Bridging) for a great overview.
For example:
NSData *inData = nil;
CFTypeRef inTypeRef = (__bridge CFTypeRef)inData;
OSStatus status = SecItemCopyMatching(
(__bridge CFDictionaryRef)searchDictionary,
&inTypeRef);
CFTypeRef inData = NULL;
OSStatus status = SecItemCopyMatching(
(__bridge CFDictionaryRef)searchDictionary,
& inData);
NSData *data = (__bridge NSData *)inData;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With