9
我有以下代碼:投間接指針的一個Objective-C的指針
OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)attrDictionary, (CFTypeRef *)&value);
導致的錯誤:
Implicit conversion of an indirect pointer to an Objective-C pointer to 'CFTypeRef *' (aka 'const void **') is disallowed with ARC
關於如何解決此問題的任何想法?我試圖改變CFTypeRef *
到id *
,但它沒有工作
下面是完整的方法:
+ (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];
}