Reputation: 12431
I am using the following code to retrieve the user's phone numbers from the address book
ABMultiValueRef phones = ABRecordCopyValue(ref, kABPersonPhoneProperty);
//EXC_BAD_ACCESS error if a user does not have phone number stored in the address book
CFStringRef pNumber = ABMultiValueCopyValueAtIndex(phones,0);
NSString *phoneNumber = [NSString stringWithFormat:@"%@", (NSString *)pNumber]
The issue arises when the user does not have a phone number in the address book, resulting in the error 'EXC_BAD_ACCESS' error. My question is how can I check if for that user, a phone number exists? And only proceed to access the value only if it exists?
Upvotes: 0
Views: 1689
Reputation: 5438
How to check the number of phone numbers.
ABMultiValueGetCount(ABRecordCopyValue(aPerson, kABPersonPhoneProperty));
Upvotes: 2