I have the following code:
OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)attrDictionary, (CFTypeRef *)&value);
which causes an error of:
Implicit conversion of an indirect pointer to an Objective-C pointer to 'CFTypeRef *' (aka 'const void **') is disallowed with ARC
Any idea on how to fix this? I have tried changing CFTypeRef * to an id * but it didn’t work out
Here’s the full method:
+ (NSData *)keychainValueForKey:(NSString *)key {
if (key == nil) {
return nil;
}
NSMutableDictionary *attrDictionary = [self attributesDictionaryForKey:key];
// Only want one match
[attrDictionary setObject:(id)kSecMatchLimitOne forKey:(id)kSecMatchLimit];
// Only one value being searched only need a bool to tell us if it was successful
[attrDictionary setObject:(id)kCFBooleanTrue forKey:(id)kSecReturnData];
NSData *value = nil;
OSStatus status = SecItemCopyMatching((CFDictionaryRef)attrDictionary, (CFTypeRef *)&value);
if (status != errSecSuccess) {
DLog(@"KeychainUtils keychainValueForKey: - Error finding keychain value for key. Status code = %d", status);
}
return [value autorelease];
}
You can just cast it to
void *:If you’re using Objective-C++ you probably have to cast it twice:
Or you can use a temporary variable: