Xcode address book shows full name instead of phone number

I have too much code to post here, so I was wondering if I could get a sample code for working with an iPhone address book map to get an idea.

Currently, when I dial the phone number from the address book, I am showing the actual phone number in the text control like this:

UI Mock

Question: Is it possible for me to just show the actual full name in the control, but behind the scenes it is possible to write down the phone number from the control.

enter image description here

I would really appreciate a sample code that deals with the structure of the iPhone address book. Thank..

+3


source to share


1 answer


I think you can already use the code like below: When you get the ID of the person from the address book,

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

      

where ID is the identifier of the address book entry.

You can get the name:



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

      

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

Hope it helps.

+1


source







All Articles