1

我在 ARC 环境中遇到类型转换问题。如果有人也愿意解决它:

当我使用这行代码时:

OSStatus status = SecItemCopyMatching((CFDictionaryRef) CFBridgingRetain(attributeQuery), (CFTypeRef*)&attributeResult);

然后我有错误:

cast of an indirect pointer to an objective C pointer to 'CFTypeRef *' is disallowed with ARC.

请建议我解决这个问题的任何方法..提前谢谢..

4

1 回答 1

2

问题是您对attributeResult 使用NSDictionary 而不是CFDictionary。试试这个,它应该可以工作(我使用的是相同的代码):

CFMutableDictionaryRef outDictionary = NULL;
if (!SecItemCopyMatching((__bridge CFDictionaryRef)tempQuery, (CFTypeRef *)&outDictionary) == noErr)
...
} else {
  // load the saved data from Keychain.
  keychainItemData = [self secItemFormatToDictionary:(__bridge NSDictionary *)outDictionary];
}
if(outDictionary) CFRelease(outDictionary);
于 2012-09-05T11:28:36.587 回答