我需要从 AddressBook 框架转换此函数的返回值:
ABRecordCopyValue(nil, kABPersonPhoneProperty)
到 ABMultiValueRef 类型的值
此功能目前标记为:
func ABRecordCopyValue(record: ABRecordRef!, property: ABPropertyID) -> Unmanaged<AnyObject>!
所以我可以像这样将它转换为非托管:
ABRecordCopyValue(person, kABPersonPhoneProperty) as Unmanaged<ABMultiValueRef>
但是我怎样才能得到它作为 ABMultiValueRef 以便我可以将它传递给这个函数呢?
func ABMultiValueGetIndexForIdentifier(multiValue: ABMultiValueRef!, identifier: ABMultiValueIdentifier) -> CFIndex
我这样做了:
let managedPhones = Unmanaged.fromOpaque(phones.toOpaque()).takeUnretainedValue() as ABMultiValueRef
而且我不断收到此编译器错误:
Bitcast requires both operands to be pointer or neither
%89 = bitcast %objc_object* %88 to %PSs9AnyObject_, !dbg !325
LLVM ERROR: Broken function found, compilation aborted!
Command /Applications/Xcode6-Beta3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 1