I am having a problem in type conversion in ARC environment.If anyone would be kind enough to address it as well:
When i used this line of code:
NSData *resultData = nil;
NSMutableDictionary *passwordQuery = [query mutableCopy];
[passwordQuery setObject: (id) kCFBooleanTrue forKey: (__bridge id) kSecReturnData];
status = SecItemCopyMatching((__bridge CFDictionaryRef) passwordQuery, (CFTypeRef *) &resultData);
Then i am recieving an error:
Cast of an indirect pointer to an Objective C pointer to 'CFTypeRef*'(aka 'const void **')is disallowed with ARC.
Please suggest me any way to ressolve this..
Thanks in advance..
The result data type is merely a CFTypeRef
until after the call to SecItemCopyMatching
so start by passing in a CFTypeRef
:
CFTypeRef resultData = nil;
status = SecItemCopyMatching((__bridge CFDictionaryRef) passwordQuery, &resultData);
Since the query specified that the resultData
should be a CFDataRef
the resultData
is now a CFDataRef
, and you can now cast it as such. then cast it further into an NSData
.
CFDataRef resultCFData = (CFDataRef)resultData;
NSData *resultNSData = (__bridge NSData *)resultCFData;
Or in one line:
NSData *resultNSData = (__bridge NSData *)(CFDataRef)resultData;
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