Ios 如何转换非托管<;CFString>;去串?
我的应用程序正在处理联系人数据 手机标签的检索如下所示Ios 如何转换非托管<;CFString>;去串?,ios,swift,cfstring,Ios,Swift,Cfstring,我的应用程序正在处理联系人数据 手机标签的检索如下所示 let locPhoneLabel : NSString = (ABMultiValueCopyLabelAtIndex(phones, numberIndex) != nil) ? ABMultiValueCopyLabelAtIndex(phones, numberIndex).takeUnretainedValue() as CFStringRef : "" let phoneLabel:Unmanaged<CFString&
let locPhoneLabel : NSString = (ABMultiValueCopyLabelAtIndex(phones, numberIndex) != nil) ? ABMultiValueCopyLabelAtIndex(phones, numberIndex).takeUnretainedValue() as CFStringRef : ""
let phoneLabel:Unmanaged<CFString> = ABAddressBookCopyLocalizedLabel(locPhoneLabel)
让locPhoneLabel:NSString=(abmultivaluecopylabelateindex(phones,numberIndex)!=nil)?ABMultiValue CopyLabelaIndex(电话,号码索引)。将UnrepainedValue()作为CFStringRef:“
let phoneLabel:Unmanaged=ABAddressBookCopyLocalizedLabel(locPhoneLabel)
我不知道如何将phoneLabel转换为NSString?试试这个:
let phoneLabel = ABAddressBookCopyLocalizedLabel(locPhoneLabel)
.takeRetainedValue() as? NSString
如果您感兴趣,这里有一个很棒的帖子。对我来说,它只会有帮助:
let locLabel : CFStringRef = (ABMultiValueCopyLabelAtIndex(phoneNumbers, i) != nil) ? (ABMultiValueCopyLabelAtIndex(phoneNumbers, i).takeUnretainedValue()) as CFStringRef : ""
let noteForThisNumber = String (ABAddressBookCopyLocalizedLabel(locLabel).takeRetainedValue())