Check if ABMultiValueRef is has no values

697 views Asked by At

I want to check if a contact in my user's addressbook a phone number has. If he does, I want to display that name in an UITableView

I've tried to check for phoneNumbers != nil, but that doesn't work. This is my entire code:

ABMultiValueRef phoneNumbers = ABRecordCopyValue(person, kABPersonPhoneProperty);

if(phoneNumbers != nil){
  [_numbers addObject:[NSString stringWithFormat:@"%@", phoneNumbers]];
}
1

There are 1 answers

0
Cooper Buckingham On BEST ANSWER

Use ABMultiValueGetCount to check if phoneNumbers has any values in it.

example based on question:

ABMultiValueRef phoneNumbers = ABRecordCopyValue(person, kABPersonPhoneProperty);

if(ABMultiValueGetCount(phoneNumbers)){
    [_numbers addObject:[NSString stringWithFormat:@"%@", phoneNumbers]];
}