I need to convert the return value of this function from the AddressBook framework:
ABRecordCopyValue(nil, kABPersonPhoneProperty)
to a value of type ABMultiValueRef
This function is currently marked as this:
func ABRecordCopyValue(record: ABRecordRef!, property: ABPropertyID) -> Unmanaged<AnyObject>!
So I can convert it to Unmanaged like so:
ABRecordCopyValue(person, kABPersonPhoneProperty) as Unmanaged<ABMultiValueRef>
But then how can I get it as an ABMultiValueRef so that I can pass it to this function?
func ABMultiValueGetIndexForIdentifier(multiValue: ABMultiValueRef!, identifier: ABMultiValueIdentifier) -> CFIndex
I did this:
let managedPhones = Unmanaged.fromOpaque(phones.toOpaque()).takeUnretainedValue() as ABMultiValueRef
And I keep getting this compiler error:
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