我正在做样本地址簿应用程序,我可以打印名字,姓氏。但是职位没有显示出来。 我使用的示例代码在这里,
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)thisPerson {
myText.text = [NSString stringWithString:@"Selected Contact:"];
myText.text = [myText.text stringByAppendingFormat:@"\n%@",
(NSString *)ABRecordCopyCompositeName(thisPerson)];
ABMutableMultiValueRef thisJob = ABRecordCopyValue(thisPerson, kABPersonJobTitleProperty);
if (thisJob != NULL) {
for (int k = 0; k < ABMultiValueGetCount(thisJob) ; k++) {
myText.text = [myText.text stringByAppendingFormat:@"\n%@: %@",
(NSString *)ABMultiValueCopyLabelAtIndex(thisJob, k),
(NSString *)ABMultiValueCopyValueAtIndex(thisJob, k)];
}
}
任何人都可以帮我解决这个问题。 谢谢。
答案 0 :(得分:0)
ABRecordCopyValue(aPerson, kABPersonJobTitleProperty);
重新调整CFStringRef而不是ABMutableMultiValueRef。
- (NSString *)jobTitleAtIndex:(NSUInteger)index {
return (NSString *)ABRecordCopyValue(aPerson, kABPersonJobTitleProperty);
}