我正在尝试从 iPhone 上的联系人中获取电话号码。我实施了
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
来自ABPeoplePickerNavigationControllerDelegate
在这种方法中有这段代码,它可以工作:
NSString *firstName = (NSString *)CFBridgingRelease(ABRecordCopyValue(person, kABPersonFirstNameProperty));
NSLog(@"First Name ---> %@" ,firstName);
NSString *secondName = (NSString *)CFBridgingRelease(ABRecordCopyValue(person, kABPersonLastNameProperty));
NSLog(@"Last name ---> %@" ,secondName);
但现在我还需要从用户那里选择电话号码。我已经尝试过,但它对我不起作用:
NSString *numberSelected = (NSString *)CFBridgingRelease(ABRecordCopyValue(person, property));
这给了我一个像这样的奇怪值:
ABMultiValueRef 0xa36e990 with 1 value(s)
0: _$!<Mobile>!$_ (0xa36ee50) - (123) 456-7890 (0xa36ee70)
然后我尝试了这个,但这也不起作用:
ABMutableMultiValueRef multi = ABRecordCopyValue(person, property);
CFStringRef phone = ABMultiValueCopyLabelAtIndex(multi, identifier);
NSLog(@"Number Selected ---> %@" ,(NSString *)CFBridgingRelease(phone));
CFRelease(phone);
NSLog(@"Number Selected --> %@" ,numberSelected);
显示的字符串只有:
_$!<Mobile>!$_
现在我不知道该怎么办......你能帮帮我吗?
谢谢!