我想为存储在 iPhone 通讯录中的联系人获取所有带有不同标签的电话号码,例如“iPhone”、“家庭电话”、“手机号码”、“其他号码”等。
我如何得到它?
请帮忙。
提前致谢。
我正在尝试:这是崩溃
ABAddressBookRef ab=ABAddressBookCreate();
CFArrayRef people = ABAddressBookCopyArrayOfAllPeople(ab);
NSMutableArray *allNumbers = [[NSMutableArray alloc] initWithCapacity:CFArrayGetCount(people)];
for (CFIndex i = 0; i < CFArrayGetCount(people); i++) {
ABRecordRef person = CFArrayGetValueAtIndex(people, i);
ABMultiValueRef numbers = ABRecordCopyValue(person, kABPersonPhoneProperty);
for (CFIndex j=0; j < ABMultiValueGetCount(numbers); j++) {
CFStringRef locLabel = ABMultiValueCopyLabelAtIndex(numbers, i);
NSString *phoneLabel =(NSString*) ABAddressBookCopyLocalizedLabel(locLabel);
CFStringRef phoneNumberRef = ABMultiValueCopyValueAtIndex(numbers, j);
CFStringRef locLabel1 = ABMultiValueCopyLabelAtIndex(numbers, j);
NSString *phoneLabel1 =(NSString*) ABAddressBookCopyLocalizedLabel(locLabel);
NSLog(@" ####### phone no -> %@ , phone label -> %@ #######)", locLabel1, phoneLabel1);
//CFRelease(phones);
NSString *phoneNumber = (NSString *)phoneNumberRef;
CFRelease(phoneNumberRef);
CFRelease(locLabel);
NSLog(@"phone no -> %@ , phone label -> %@)", phoneNumber, phoneLabel);
[phoneNumber release];
}
CFRelease(numbers);
}
CFRelease(people);