0

I have a requirement to determine if a contact that is saved in the address book has multiple mobile numbers.

I have the record ID of a Contact and I need to check if that contact has multiple mobile numbers.

Is this possible?

Jonny C
  • 1,943
  • 3
  • 20
  • 36
Pradeep Reddy Kypa
  • 3,992
  • 7
  • 57
  • 75
  • 1
    What have you tried, where is the code where you are try to count the numbers? You question looks a lot like a code request which is frowned up and might get you done voted. – rckoenes Oct 07 '15 at 08:23

1 Answers1

0

Got the Answer!!! I have written a method to get the total count of mobile numbers for a contact

-(NSInteger)getCountOfTotalMobileNumbersForContact:(ContactData *)contactData{
NSInteger totalCountOfMobileNumbers = 0;

ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, NULL);
ABRecordRef contact = ABAddressBookGetPersonWithRecordID(addressBook, (int)contactData.mRecordID);
if(contact != nil)
{
    self.phoneNumbers = ABRecordCopyValue(contact, kABPersonPhoneProperty);
    NSString *lFirstName = (__bridge_transfer NSString*)ABRecordCopyValue(contact, kABPersonFirstNameProperty);
    NSString *lLastName = (__bridge_transfer NSString*)ABRecordCopyValue(contact, kABPersonLastNameProperty);

    NSString *fullName = lFirstName;

    if (lLastName.length) {
        fullName = [[lFirstName stringByAppendingString:@" "] stringByAppendingString:lLastName];
    }
    totalCountOfMobileNumbers = ABMultiValueGetCount(self.phoneNumbers);
}

return totalCountOfMobileNumbers;
}
Pradeep Reddy Kypa
  • 3,992
  • 7
  • 57
  • 75