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>!$_
今、私は何をすべきかわかりません...あなたは私を助けることができますか?
ありがとう!