Skip to content

Instantly share code, notes, and snippets.

@marshluca
Created November 29, 2010 08:32
Show Gist options
  • Save marshluca/719731 to your computer and use it in GitHub Desktop.
Save marshluca/719731 to your computer and use it in GitHub Desktop.
获取iPhone联系人
- (void)getContactList
{
ABAddressBookRef addressBook = ABAddressBookCreate();
NSMutableArray *peopleArray = (NSMutableArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);
for (id *people in peopleArray)
{
// phone
ABMultiValueRef phones = (ABMultiValueRef) ABRecordCopyValue(people, kABPersonPhoneProperty);
int nCount = ABMultiValueGetCount(phones);
for(int i = 0 ;i < nCount;i++)
{
NSString *phonelLable = (NSString *)ABMultiValueCopyLabelAtIndex(phones, i);
NSString *phoneNO = (NSString *)ABMultiValueCopyValueAtIndex(phones, i); // 这个就是电话号码
NSLog(@"phone: %@,%@",phonelLable,phoneNO);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment