That's because this line
ABMultiValueCopyValueAtIndex(phoneNumbers, 0);
tells it to get the first phone number, i.e "Home" number.
See this post: Access to people info in iPhone address book
Question
I followed Apple's tutorial on obtaining a contact's phone number and it works great but it only detects phone numbers with the "Home" label. Here is my code:
- (void)displayPerson:(ABRecordRef)person {
NSString* phone = nil;
ABMultiValueRef phoneNumbers = ABRecordCopyValue(person,
kABPersonPhoneProperty);
if (ABMultiValueGetCount(phoneNumbers) > 0) {
phone = (__bridge_transfer NSString*)
ABMultiValueCopyValueAtIndex(phoneNumbers, 0);
} else {
phone = @"[None]";
}
self.contactNumber.text = phone;
CFRelease(phoneNumbers); }
Anyone know why it is doing this?
Solution
That's because this line
ABMultiValueCopyValueAtIndex(phoneNumbers, 0);
tells it to get the first phone number, i.e "Home" number.
See this post: Access to people info in iPhone address book