我需要将来自AddressBook框架的此函数返回值进行转换:
ABRecordCopyValue(nil, kABPersonPhoneProperty)
转换为类型为ABMultiValueRef的值。
当前将此函数标记为:
func ABRecordCopyValue(record: ABRecordRef!, property: ABPropertyID) -> Unmanaged<AnyObject>!
那么我可以这样将它转换为Unmanaged:
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