0

I'm using the code provided from the accepted answer at Retrieve all contacts phone numbers in iOS and I've noticed a lot of contacts are missing. I'm pretty sure they're contacts stored on the SIM card and somehow ABAddressBookCopyArrayOfAllPeople doesn't retrieve contacts from the SIM card. If I use ABPeoplePickerNavigationController the contacts do appear, but that isn't suitable for what I'm building.

Does anyone know how to overcome this issue?

Thanks

Community
  • 1
  • 1
Michael Bates
  • 1,884
  • 2
  • 29
  • 40

1 Answers1

0

Missing contacts in ABAddressBookCopyArrayOfAllPeople had the answer. Although it wasn't entirely clear at first what the poster did, the main thing was casting the ABMultiValueRef to an NSArray like so:

ABMultiValueRef phones = (__bridge ABMultiValueRef)((__bridge NSString*)ABRecordCopyValue(ref, kABPersonPhoneProperty));
NSArray *phoneNumbers = (__bridge NSArray *)ABMultiValueCopyArrayOfAllValues(phones);

After that phoneNumbers contains every phone number for the current ABPerson.

Community
  • 1
  • 1
Michael Bates
  • 1,884
  • 2
  • 29
  • 40