我想在不使用iOS Navigation Picker
的情况下获取我的iPhone联系人列表。
这是我写的代码......但是它没有用,你知道为什么吗?
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, NULL);
CFArrayRef allPeopleRef = ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering(addressBook, nil, kABPersonSortByFirstName);
CFIndex nPeople = ABAddressBookGetPersonCount(addressBook);
for(int i=0; i<nPeople; i++){
ABRecordRef ref = CFArrayGetValueAtIndex(allPeopleRef, i );
CFStringRef tmpStringRef = ABRecordCopyValue(ref, kABPersonFirstNameProperty);
NSLog(@"FirstName: %@", (__bridge NSString *)tmpStringRef);
CFRelease(tmpStringRef);
}
CFRelease(allPeopleRef);
CFRelease(addressBook);