Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

Next Page > Hide TOC

ABRecord Class Objective-C Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AddressBook.framework
Availability
Available in Mac OS X v10.2 and later.
Companion guide
Declared in
ABRecord.h
ABTypedefs.h

Overview

ABRecord is an abstract superclass providing a common interface to and defining common properties for all Address Book records. A property is a field in the database record such as the first or last name of a person record. ABRecord defines the types of properties supported, and basic methods for getting, setting, and removing property values.

Use valueForProperty: to get a record’s property value, use setValue:forProperty: to set a value, and removeValueForProperty: to remove a value. Don’t just invoke setValue:forProperty: with nil as the property value argument, it will raises an exception.

Each record in the Address Book database has a corresponding unique ID obtained using the uniqueId method. The unique ID is used by other classes in the AddressBook framework.

Use isReadOnly to determine whether or not a record is read-only.

The ABRecord class is “toll-free bridged” with its procedural C, opaque type, counterpart. This means that the ABRecordRef type is interchangeable in function or method calls with instances of the ABRecord class.

Tasks

Initializing

Retrieving and Setting Values

Retrieving a Specific Record

Determining Properties

Instance Methods

initWithAddressBook:

Initializes the receiver and adds it to the given address book.

- (id)initWithAddressBook:(ABAddressBook *)addressBook

Parameters
addressBook

An address book that you want to initialize the receiver with.

Discussion

The receiver is added to addressBook but is not visible to other address books until addressBook is saved. This is the designated initializer for this class.

Availability
Declared In
ABRecord.h

isReadOnly

- (BOOL)isReadOnly

Discussion

Returns YES if the record is read-only, NO otherwise.

Availability
Declared In
ABRecord.h

removeValueForProperty:

- (BOOL)removeValueForProperty:(NSString *)property

Discussion

Removes the value for a given property. When you next call valueForProperty: on that property, it returns nil.

If property is nil, this method raises an exception. This method returns YES if the value is removed successfully, NO otherwise.

Availability
Declared In
ABRecord.h

setValue:forProperty:

- (BOOL)setValue:(id)value forProperty:(NSString *)property

Discussion

Sets the value of a given property for a record. The type of the value must match the property’s type (see “Constants” for a list of possible property types). If property is nil or if value is not of the correct type, this method raises an exception. If property is a multi-value list property, this method checks to see if the values in the multi-value list are the same type. If the multi-value list contains mixed types, this method returns NO. This method returns YES if the value was set successfully, and NO otherwise.

Availability
Declared In
ABRecord.h

uniqueId

- (NSString *)uniqueId

Discussion

Returns the unique ID of the receiver. This method is equivalent to invoking valueForProperty: passing kABUIDProperty as the argument.

Availability
See Also
Declared In
ABRecord.h

valueForProperty:

- (id)valueForProperty:(NSString *)property

Discussion

Returns the value of the given property. The type of the value depends on the property type (see “Constants” for a list of possible property types). Note that the retuned value is always of an immutable type (for example, an NSString not an NSMutableString is returned).

If property is nil, this method raises an exception.

Availability
Declared In
ABRecord.h

Constants

These are of type ABPropertyType and describe the possible types for ABRecord properties:

Constant

Description

kABStringProperty

Indicates a NSString object.

Available in Mac OS X v10.2 and later.

Declared in ABTypedefs.h

kABIntegerProperty

Indicates a NSNumber object representing an integer.

Available in Mac OS X v10.2 and later.

Declared in ABTypedefs.h

kABRealProperty

Indicates a NSNumber object representing a real number.

Available in Mac OS X v10.2 and later.

Declared in ABTypedefs.h

kABDateProperty

Indicates a NSDate object.

Available in Mac OS X v10.2 and later.

Declared in ABTypedefs.h

kABArrayProperty

Indicates a NSArray object.

Available in Mac OS X v10.2 and later.

Declared in ABTypedefs.h

kABDictionaryProperty

Indicates a NSDictionary object.

Available in Mac OS X v10.2 and later.

Declared in ABTypedefs.h

kABDataProperty

Indicates a NSData object.

Available in Mac OS X v10.2 and later.

Declared in ABTypedefs.h

kABMultiStringProperty

Indicates a ABMultiValue containing NSString objects.

Available in Mac OS X v10.2 and later.

Declared in ABTypedefs.h

kABMultiIntegerProperty

Indicates a ABMultiValue containing NSNumber objects representing integers.

Available in Mac OS X v10.2 and later.

Declared in ABTypedefs.h

kABMultiRealProperty

Indicates a ABMultiValue containing NSNumber objects representing real numbers.

Available in Mac OS X v10.2 and later.

Declared in ABTypedefs.h

kABMultiDateProperty

Indicates a ABMultiValue containing NSDate objects.

Available in Mac OS X v10.2 and later.

Declared in ABTypedefs.h

kABMultiArrayProperty

Indicates a ABMultiValue containing NSArray objects.

Available in Mac OS X v10.2 and later.

Declared in ABTypedefs.h

kABMultiDictionaryProperty

Indicates a ABMultiValue containing NSDictionary objects.

Available in Mac OS X v10.2 and later.

Declared in ABTypedefs.h

kABMultiDataProperty

Indicates a ABMultiValue containing NSData objects.

Available in Mac OS X v10.2 and later.

Declared in ABTypedefs.h

kABErrorInProperty

Returned by some methods when an invalid property is used.

Available in Mac OS X v10.2 and later.

Declared in ABTypedefs.h

These properties are in all types of records.

Constant

Description

kABUIDProperty

The unique ID for this record. It’s guaranteed never to change, no matter how much the record changes. If you need to store a reference to an ABRecord, use this value. (NSString)

kABCreationDateProperty

The date when the record was first saved (NSDate)

kABModificationDateProperty

The date when the record was last saved (NSDate)



Next Page > Hide TOC


Last updated: 2006-07-26




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice