11.4. Retrieving Properties of Address Book Entries
You have retrieved a reference to an item in the address book, such as a person’s entry, and you want to retrieve that person’s properties, such as first and last names.
function on the person’s Address Book record.
The records in the address book database are of type
ABRecordRef. Each record could be either a
group or a person. We have not discussed groups yet, so let’s focus on
people. Each person could have various types of information assigned to
him, such as his first name, last name, email address, and so on. Bear
in mind that many of these values are optional, and at the time of
creating a new contact in the address book database, the user can simply
leave out fields such as phone number, middle name, email address, URL,
and so forth.
ABRecordCopyValue accepts an
address book record and the property that has to be retrieved as its two
parameters. The second parameter is the property of the record that we
want to retrieve. Here are some of the common properties (all of these
properties are defined as constant values in the ABPerson.h header file):
This value will retrieve the first name of the given person. The return value is of type
CFStringRef, which can be cast to
NSStringwith a bridge cast, so you can do just about anything you want with the results.
This value will retrieve the last name of the given person. Like the first ...