ABAddressBookRef currentAddressBook = ABAddressBookCreate();
CFArrayRef contactArray = ABAddressBookCopyArrayOfAllPeople(currentAddressBook);
NSArray *myContactArray = (NSArray *)contactArray;
for(int i = 0; i < [myContactArray count]; i++){
ABRecordRef people = (ABRecordRef)[myContactArray objectAtIndex:i];
CFStringRef firstName = ABRecordCopyValue(people, kABPersonFirstNameProperty);
CFStringRef midName = ABRecordCopyValue(people, kABPersonMiddleNameProperty);
CFStringRef lastName = ABRecordCopyValue(people, kABPersonLastNameProperty);
NSMutableString *fullName = [NSMutableString string];
if([(NSString *)firstName length] > 0){
[fullName appendString:(NSString *)firstName];
}
if([(NSString *)midName length] > 0){
[fullName appendString:(NSString *)midName];
}
if([(NSString *)lastName length] > 0){
[fullName appendString:(NSString *)lastName];
}
NSLog(@"%@",fullName);
}
iPhone 读取电话本数据
最新推荐文章于 2024-07-13 23:58:05 发布