5

My application is dealing with contacts data.

The phone label is retrieved as following

let locPhoneLabel : NSString = (ABMultiValueCopyLabelAtIndex(phones, numberIndex) != nil) ? ABMultiValueCopyLabelAtIndex(phones, numberIndex).takeUnretainedValue() as CFStringRef : ""

let phoneLabel:Unmanaged<CFString> = ABAddressBookCopyLocalizedLabel(locPhoneLabel)

I don't know how to convert phoneLabel to NSString?

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Colateral
  • 1,736
  • 2
  • 18
  • 22

2 Answers2

12

Try this:

let phoneLabel = ABAddressBookCopyLocalizedLabel(locPhoneLabel)
.takeRetainedValue() as? NSString

There is a great post here if you are interested.Unmanaged from NSHipster.

tounaobun
  • 14,570
  • 9
  • 53
  • 75
0

For me it only helped:

let locLabel : CFStringRef = (ABMultiValueCopyLabelAtIndex(phoneNumbers, i) != nil) ? (ABMultiValueCopyLabelAtIndex(phoneNumbers, i).takeUnretainedValue()) as CFStringRef : ""
let noteForThisNumber = String (ABAddressBookCopyLocalizedLabel(locLabel).takeRetainedValue())
Paul T.
  • 4,938
  • 7
  • 45
  • 93