Type conversion causing compilation error in ARC environment

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..

Answers


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;

Need Your Help

Setting the startDate on Datepicker

jquery twitter-bootstrap datepicker

I am trying to create a calendar using bootstrap datepicker that allows users to select a day starting 24 hours from today. I saw this question posted on SO before but when I try the solution sugg...

jQuery - click event is not firing

javascript php jquery

Hello I try to make my table rows click able.