Created
November 29, 2010 08:32
-
-
Save marshluca/719731 to your computer and use it in GitHub Desktop.
获取iPhone联系人
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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