dotnet-practitioner
dotnet-practitioner

Reputation: 14148

Xcode address book show full name instead of phone number

I have too much code to post here so I was wondering if I could get some code sample regarding iPhone address-book frame work to get an idea.

currently when I pick up phone number from address book, I show actual phone number in the text control as follows:

UI Mock

Question: Is it possible for me to just show actual full name in the control but behind the scenes be able to capture phone number from the control.

enter image description here

I would very much appreciate the sample code that deals with iPhone address-book framework. Thanks..

Upvotes: 3

Views: 989

Answers (1)

Nameet
Nameet

Reputation: 650

I think you might be already using code something like below: Once you get the ID of the person from address book,

ABAddressBookRef addressBook = ABAddressBookCreate();
ABRecordRef recordRef = ABAddressBookGetPersonWithRecordID(addressBook,ID);
ABMutableMultiValueRef emailMultiValue = ABRecordCopyValue(recordRef, kABPersonPhoneProperty);

where ID is the record id from address book.

You can get the name by:

NSString *firstName = (NSString *)ABRecordCopyValue(recordRef, kABPersonFirstNameProperty);
NSString *lastName = (NSString *)ABRecordCopyValue(recordRef, kABPersonLastNameProperty);

So now you have the name and number. And you can just show actual full name in the control but behind the scenes you can capture phone number from the control.

Hope this helps.

Upvotes: 1

Related Questions