2015-10-07 20 views

回答

0

得到答案!!!我寫了一個方法來獲得一個聯繫人的手機號碼總數

-(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; 
} 
相關問題