| Derived from | |
| Framework | AddressBook/ABAddressBookC.h |
| Companion guide | |
| Declared in | ABAddressBookC.h ABGlobals.h ABTypedefs.h |
The ABAddressBook opaque type provides a programming interface to the Address Book—a centralized database used by multiple applications to store contact and other personal information about people. The Address Book database also supports the notion of a “group” containing one or more persons. People may belong to multiple groups, and groups may also belong to other groups.
The ABAddressBook opaque type provides functions for accessing,
adding, and removing group and person records including the “me”
record corresponding to the logged-in user. For example, you use
the ABCopyArrayOfAllGroups function
to get an array of all the group records in the database, or the ABCopyArrayOfAllPeople function
to get all the person records. You use the ABGetMe function to get the person record
corresponding to the logged-in user. You can also add and remove
records using the ABAddRecord and ABRemoveRecord functions.
You can also search for records matching a particular query
you specify by creating an ABSearchElement object. You use the ABGroupCreateSearchElement or ABPersonCreateSearchElement function
to create an ABSearchElement object for the corresponding record.
Then use the ABCopyArrayOfMatchingValues ABAddressBook
function, passing the ABSearchElement as the argument, to query
the database. See ABSearchElement for
more functions that create compound queries.
Your application uses a shared instance of ABAddressBook returned
by the ABGetSharedAddressBook function
to interact with the database (multiple ABAddressBook instances
are not supported). Changes you make to the record objects are stored
in memory, and saved to disk when you invoke the ABSave function.
The Address Book posts notifications if any application including
yours makes changes to the database. Typically, you observe these
notifications to update any dependent view or model objects in your
application. Use CFNotificationCenter to register for the ABAddressBook
notifications: kABDatabaseChangedNotification and kABDatabaseChangedExternallyNotification. These notifications are not sent until ABGetSharedAddressBook is called.
The ABAddressBook opaque type is “toll-free bridged” with
its Objective-C counterpart. This means that the ABAddressBookRef type
is interchangeable in function or method calls with instances of
the ABAddressBook class.
Adds the given properties to all the records of the specified type in the Address Book database, and returns the number of properties successfully added.
CFIndex ABAddPropertiesAndTypes ( ABAddressBookRef addressBook, CFStringRef recordType, CFDictionaryRef propertiesAnTypes );
The address book for the logged-in user.
The record type you wish to add properties to: kABGroupRecordType or kABPersonRecordType.
A CFDictionary object containing the properties to add. In each dictionary entry, the key is a string with the property’s name, and the value is a constant with the property’s type. The property’s name must be unique. You may want to use Java-style package names for your properties, for example, "org.dogclub.dogname" or "com.mycompany.customerID". The property type must be one of the constants described in Property Types.
The number of properties successfully added.
ABAddressBookC.hAdds a record of the specified type to the Address Book database.
bool ABAddRecord ( ABAddressBookRef addressBook, ABRecordRef record );
The address book for the logged-in user.
The record to add to the Address Book database. If this parameter is NULL, the function raises an exception.
true if the record was added successfully, false otherwise.
ABAddressBookC.hReturns an array of all the groups in the Address Book database.
CFArrayRef ABCopyArrayOfAllGroups ( ABAddressBookRef addressBook );
The address book for the logged-in user.
An array of ABGroup objects representing all the groups in the Address Book database. If the database doesn’t contain any groups, the function returns an empty array. You are responsible for releasing this object.
ABAddressBookC.hReturns an array of all the people in the Address Book database.
CFArrayRef ABCopyArrayOfAllPeople ( ABAddressBookRef addressBook );
The address book for the logged-in user.
An array of ABPerson objects representing all the people in the Address Book database. If the database does not contain any people, the function returns an empty array. You are responsible for releasing this object.
ABAddressBookC.hReturns an array of records that match the given search element, or an empty array if no records match the search element.
CFArrayRef ABCopyArrayOfMatchingRecords ( ABAddressBookRef addressBook, ABSearchElementRef search );
The address book for the logged-in user.
The search element that specifies the query. If search is NULL, this function raises an exception. Create an ABSearchElement object using the record specific functions: ABGroupCreateSearchElement or ABPersonCreateSearchElement. See ABSearchElement for more functions that create compound queries.
A new array containing ABRecord objects representing all the records that match search. If no records match search, this function returns an empty array. You are responsible for releasing this object.
ABAddressBookC.hReturns an array containing the names of all the properties for the specified record type.
CFArrayRef ABCopyArrayOfPropertiesForRecordType ( ABAddressBookRef addressBook, CFStringRef recordType );
The address book for the logged-in user.
Specifies the type of record: kABGroupRecordType or kABPersonRecordType.
An new array containing the names (CFString objects) of all the properties in recordType. You are responsible for releasing this object.
ABAddressBookC.hReturns the default country code for records with unspecified country codes.
CFStringRef ABCopyDefaultCountryCode ( ABAddressBookRef addressBook );
The address book for the logged-in user.
A string with the default country code. You are responsible for releasing this object.
ABAddressBookC.hReturns the record that matches the given unique ID.
ABRecordRef ABCopyRecordForUniqueId ( ABAddressBookRef addressBook, CFStringRef uniqueId );
The address book for the logged-in user.
A unique ID for the record. If this is NULL, this function raises an exception.
The record that matches the given unique ID. If no record matches uniqueId, the function returns NULL. You are responsible for releasing this object.
ABAddressBookC.hReturns the type name of the record that matches a given unique ID.
CFStringRef ABCopyRecordTypeFromUniqueId ( ABAddressBookRef addressBook, CFStringRef uniqueId );
The address book for the logged-in user.
A unique ID for the record. If this is NULL, this function raises an exception.
A string with the name of the type for the record that matches the given unique ID. You are responsible for releasing this object.
ABAddressBookC.hReturns a string containing the formatted address.
CFStringRef ABCreateFormattedAddressFromDictionary ( ABAddressBookRef addressBook, CFDictionaryRef address );
The address book for the logged-in user.
Returns a string containing the formatted address. You are responsible for releasing this object.
ABAddressBookC.hReturns the ABPerson object for the logged-in user.
ABPersonRef ABGetMe ( ABAddressBookRef addressBook );
The address book for the logged-in user.
The ABPerson record that represents the logged-in user, or NULL if the user never specified such a record. You are responsible for retaining and releasing this object as needed.
ABAddressBookC.hReturns the unique shared ABAddressBook object.
ABAddressBookRef ABGetSharedAddressBook ( void );
The address book for the logged-in user. You are responsible for retaining and releasing this object as needed.
Every application shares the address book for the logged-in user and this function returns it. If you call this function more than once or try to create a new address book, you get a pointer to the same shared address book.
ABAddressBookC.hReturns whether if there are unsaved changes in the address book.
bool ABHasUnsavedChanges ( ABAddressBookRef addressBook );
The address book for the logged-in user.
true if there are unsaved changes, false otherwise.
The unsaved changes flag is set automatically whenever changes are made to the address book.
ABAddressBookC.hRemoves the given properties from all the records of this type in the Address Book database, and returns the number of properties successfully removed.
CFIndex ABRemoveProperties ( ABAddressBookRef addressBook, CFStringRef recordType, CFArrayRef properties );
The address book for the logged-in user.
The name of record to remove the properties from: kABGroupRecordType or kABPersonRecordType.
An array of properties (CFString objects) to remove.
The number of properties successfully removed.
ABAddressBookC.hRemoves the specified record from the Address Book database.
bool ABRemoveRecord ( ABAddressBookRef addressBook, ABRecordRef record );
The address book for the logged-in user.
The ABRecord object to be removed. If NULL, this function raises an exception.
true if the record was removed successfully, false otherwise.
ABAddressBookC.hSaves all the changes made since the last save.
bool ABSave ( ABAddressBookRef addressBook );
The address book for the logged-in user.
true if this function is successful or if there were no changes, false otherwise.
ABAddressBookC.hSets the record that represents the logged-in user.
void ABSetMe ( ABAddressBookRef addressBook, ABPersonRef moi );
The address book for the logged-in user.
The ABPerson object that represents the logged-in user. Pass NULL if you don’t want a record to represent the logged-in user.
ABAddressBookC.hReturns the type of a given property for a given record.
ABPropertyType ABTypeOfProperty ( ABAddressBookRef addressBook, CFStringRef recordType, CFStringRef property );
The address book for the logged-in user.
The record type that contains property: kABGroupRecordType or kABPersonRecordType.
The property whose type you wish to obtain.
The type of property as defined in Property Types. If property does not exist in recordType, this function returns kABErrorInProperty.
ABAddressBookC.hA reference to an ABAddressBook object.
typedef struct __ABAddressBookRef *ABAddressBookRef;
ABAddressBookC.hThese are the possible types of ABRecord properties.
typedef enum _ABPropertyType { kABErrorInProperty = 0x0, kABStringProperty = 0x1, kABIntegerProperty = 0x2, kABRealProperty = 0x3, kABDateProperty = 0x4, kABArrayProperty = 0x5, kABDictionaryProperty = 0x6, kABDataProperty = 0x7, kABMultiStringProperty = 0x100 | kABStringProperty, kABMultiIntegerProperty = 0x100 | kABIntegerProperty, kABMultiRealProperty = 0x100 | kABRealProperty, kABMultiDateProperty = 0x100 | kABDateProperty, kABMultiArrayProperty = 0x100 | kABArrayProperty, kABMultiDictionaryProperty = 0x100 | kABDictionaryProperty, kABMultiDataProperty = 0x100 | kABDataProperty } ABPropertyType;
kABErrorInPropertyReturned by some functions when an invalid property is used.
Available in Mac OS X v10.2 and later.
Declared in ABTypedefs.h.
kABStringPropertyIndicates a CFString object.
Available in Mac OS X v10.2 and later.
Declared in ABTypedefs.h.
kABIntegerPropertyIndicates a CFNumber object representing an integer.
Available in Mac OS X v10.2 and later.
Declared in ABTypedefs.h.
kABRealPropertyIndicates a CFNumber object representing a real number.
Available in Mac OS X v10.2 and later.
Declared in ABTypedefs.h.
kABDatePropertyIndicates a CFDate object.
Available in Mac OS X v10.2 and later.
Declared in ABTypedefs.h.
kABArrayPropertyIndicates a CFArray object.
Available in Mac OS X v10.2 and later.
Declared in ABTypedefs.h.
kABDictionaryPropertyIndicates a CFDictionary object.
Available in Mac OS X v10.2 and later.
Declared in ABTypedefs.h.
kABDataPropertyIndicates a CFData object.
Available in Mac OS X v10.2 and later.
Declared in ABTypedefs.h.
kABMultiStringPropertyIndicates an ABMultiValue containing NSString objects.
Available in Mac OS X v10.2 and later.
Declared in ABTypedefs.h.
kABMultiIntegerPropertyIndicates an ABMultiValue containing NSNumber objects representing integers.
Available in Mac OS X v10.2 and later.
Declared in ABTypedefs.h.
kABMultiRealPropertyIndicates an ABMultiValue containing NSNumber objects representing real numbers.
Available in Mac OS X v10.2 and later.
Declared in ABTypedefs.h.
kABMultiDatePropertyIndicates an ABMultiValue containing NSDate objects.
Available in Mac OS X v10.2 and later.
Declared in ABTypedefs.h.
kABMultiArrayPropertyIndicates an ABMultiValue containing NSArray objects.
Available in Mac OS X v10.2 and later.
Declared in ABTypedefs.h.
kABMultiDictionaryPropertyIndicates an ABMultiValue containing NSDictionary objects.
Available in Mac OS X v10.2 and later.
Declared in ABTypedefs.h.
kABMultiDataPropertyIndicates an ABMultiValue containing NSData objects.
Available in Mac OS X v10.2 and later.
Declared in ABTypedefs.h.
These are notifications published when something changes in the Address Book database. These notifications are not sent until ABGetSharedAddressBook has been called.
CFStringRef kABDatabaseChangedNotification; CFStringRef kABDatabaseChangedExternallyNotification;
kABDatabaseChangedNotificationThis process has changed the AddressBook database.
Available in Mac OS X v10.2 and later.
Declared in ABGlobals.h.
kABDatabaseChangedExternallyNotificationAnother process has changed the AddressBook database. The following keys are included in the user-info dictionary of the notification: kABInsertedRecords, kABUpdatedRecords, and kABDeletedRecords. If the values for all the keys are nil, everything has changed, such as when the Address Book database is restored from a backup copy.
Available in Mac OS X v10.2 and later.
Declared in ABGlobals.h.
Last updated: 2007-07-08