How do I get a value as a Swift type from an object of type Unmanaged<AnyObject>
. My example is using an ABRecordRef
I'm creating a contact object to manage once I get the ABRecordRef
, but I'm having trouble translating from ObjC. Here's what I have:
init(recordRef: ABRecordRef) {
if let firstName = ABRecordCopyValue(recordRef, kABPersonFirstNameProperty) {
self.firstName = firstName
}
}
If it were ObjC, I would do:
CFTypeRef firstNameRef = ABRecordCopyValue(recordRef, kABPersonFirstNameProperty);
if (firstNameRef) {
self.firstName = (__bridge NSString *)firstNameRef;
}
I can't seem to find the right combination of downcasting / conversion, so any help is appreciated.