After much searching, I'm stuck with a problem that (I believe) hasn't been clearly addressed.
My goal is to pull phone numbers from the phone's contact list. Permission has already been granted. I use this bit of code to extract data from a given contact (variable 'person'):
let unmanagedPhones: ABMultiValueRef = ABRecordCopyValue(person, kABPersonPhoneProperty).takeUnretainedValue()
println("unmanagedPhone: \(unmanagedPhones)")
For some of the contacts on my phone, this returns the following (I've censored some of the numbers with #'s):
unmanagedPhone: ABMultiValueRef 0x170468d00 with 2 value(s) 0: $!Mobile!$ (0x#########) - 1 (###) ###-#### (0x170#45###) 1: $!Work!$ (0x#########) - 1 (###) ###-#### (0x#70##3#a0)
For many others, though, this returns:
unmanagedPhone: ABMultiValueRef 0x170474a40 with 0 value(s)
I've confirmed that the contacts in question do have at least one number. In exploring the address book, I can't figure out why some contacts work and others don't. Does anyone have any advice or direction as to how to begin to debug this? Thanks, all!
Using Swift on Xcode 6.4, iOS 8.
Try this: