AddressBook

The AddressBook framework was released with Mac OS X 10.2. This framework provides a consistent, system-wide interface to a user’s database of personal contacts. Using the AddressBook framework, applications can access the same information used in Apple’s own suite of personal information management applications, including Mail, Address Book, iChat, iCal, and iSync. Figure 8-1 shows the AddressBook framework’s class hierarchy.

The AddressBook framework class hierarchy
Figure 8-1. The AddressBook framework class hierarchy

ABAddressBook is the main class representing the contacts database. The ABAddressBook class provides access to a collection of records, of two types: people and groups, represented by the classes ABPerson and ABGroup. ABPerson and ABGroup inherit from the class ABRecord , as shown in Figure 8-1. Records are like souped-up dictionaries that store information in property-value pairs (similar to NSDictionary’s key-value pairs, but ABRecord properties provide additional functionality).

Both people and group objects store properties, but they are not the same set of properties since a group does not share the characteristics of an individual. To retrieve the value of a property associated with a record, invoke the method valueForProperty: in the ABRecord object in question. To store a value for a record’s property, use the method setValue:forProperty:.

ABAddressBook provides methods that access records ...

Get Cocoa in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.