我的问题涉及围绕iPhone上联系人列表的Person条目中的某些默认电话号码标签的标记.
我为一个人创建了一个iPhone联系人列表通讯录条目,"John Smith",其中包含以下电话号码条目:
请注意,前五个标签是"联系人"应用程序提供的默认标签,最后一个标签"megaphone"是自定义标签.
我编写了以下方法来检索和显示地址簿中每个人的标签和电话号码:
-(void)displayPhoneNumbersForAddressBook {
ABAddressBookRef book = ABAddressBookCreate();
CFArrayRef people = ABAddressBookCopyArrayOfAllPeople(book);
ABRecordRef record = CFArrayGetValueAtIndex(people, 0);
ABMultiValueRef multi = ABRecordCopyValue(record, kABPersonPhoneProperty);
NSLog(@"---------" );
NSLog(@"displayPhoneNumbersForAddressBook" );
CFStringRef label, phone;
for (CFIndex i = 0; i < ABMultiValueGetCount(multi); ++i) {
label = ABMultiValueCopyLabelAtIndex(multi, i);
phone = ABMultiValueCopyValueAtIndex(multi, i);
NSLog(@"label: \"%@\" number: \"%@\"", (NSString*)label, (NSString*)phone);
CFRelease(label);
CFRelease(phone);
}
NSLog(@"---------" );
CFRelease(multi);
CFRelease(people);
CFRelease(book);
}
Run Code Online (Sandbox Code Playgroud)
这是我输入的地址簿条目的输出:
2010-03-08 13:24:28.789 test2m[2479:207] ---------
2010-03-08 13:24:28.789 test2m[2479:207] displayPhoneNumbersForAddressBook …Run Code Online (Sandbox Code Playgroud)