Mac Developer Library

Developer

AddressBook Framework Reference ABRecord C Reference

Options
Deployment Target:

On This Page
Language:

ABRecord C Reference

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import AddressBook

Objective-C

@import AddressBook;

ABRecord is an abstract opaque type providing a common interface to and defining common properties for all records in the Address Book database. 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 functions for getting, setting, and removing property values.

Use ABRecordCopyValue to get a record’s property value, use ABRecordSetValue to set a value, and ABRecordRemoveValue to remove a value.

Each record in the Address Book database has a corresponding unique ID obtained using the ABRecordCopyUniqueId function. The unique ID is used by other functions in the AddressBook framework.

You can check if a record is read-only by using the ABRecordIsReadOnly function.

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

Functions

  • Returns the type of the given record.

    Declaration

    Swift

    func ABRecordCopyRecordType(_ record: ABRecordRef) -> Unmanaged<CFString>!

    Objective-C

    CFStringRef ABRecordCopyRecordType ( ABRecordRef record );

    Parameters

    record

    The record whose type you wish to obtain.

    Return Value

    The type of record, one of the kAB...RecordType constants. You are responsible for releasing this object.

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

  • Returns the unique ID of the receiver.

    Declaration

    Swift

    func ABRecordCopyUniqueId(_ record: ABRecordRef) -> Unmanaged<CFString>!

    Objective-C

    CFStringRef ABRecordCopyUniqueId ( ABRecordRef record );

    Parameters

    record

    The record whose unique ID you wish to obtain.

    Return Value

    The unique ID corresponding to record. You are responsible for releasing this object.

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

  • Returns the value of the given property.

    Declaration

    Swift

    func ABRecordCopyValue(_ record: ABRecordRef, _ property: CFString!) -> Unmanaged<AnyObject>!

    Objective-C

    CFTypeRef ABRecordCopyValue ( ABRecordRef record, CFStringRef property );

    Parameters

    record

    The record whose value you wish to obtain.

    property

    The property name in record whose value you wish to obtain. May be a pre-defined or program-defined property. See Common Properties for a list of properties all records have, and specific ABRecord derived opaque types for any additional properties.

    Return Value

    The value for property in record. The type of the returned value depends on the property type (see Property Types for a list of possible property types). You are responsible for releasing this object.

    If the value for property is invalid, this function returns NULL.

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

  • Returns a copy of the given record.

    Declaration

    Swift

    func ABRecordCreateCopy(_ record: ABRecordRef) -> ABRecordRef

    Objective-C

    ABRecordRef ABRecordCreateCopy ( ABRecordRef record );

    Parameters

    record

    The record you wish to copy.

    Return Value

    A copy of the specified ABRecordRef.

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.4 and later.

  • Returns whether or not the record is read-only.

    Declaration

    Swift

    func ABRecordIsReadOnly(_ record: ABRecordRef) -> Bool

    Objective-C

    bool ABRecordIsReadOnly ( ABRecordRef record );

    Parameters

    record

    The record you wish to check.

    Return Value

    true if record is read-only, false otherwise.

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.4 and later.

  • Removes the value of the given property.

    Declaration

    Swift

    func ABRecordRemoveValue(_ record: ABRecordRef, _ property: CFString!) -> Bool

    Objective-C

    bool ABRecordRemoveValue ( ABRecordRef record, CFStringRef property );

    Parameters

    record

    The record whose value you wish to remove.

    property

    The property name in record whose value you wish to remove. May be a pre-defined or program-defined property. See Common Properties for a list of properties all records have, and specific ABRecord derived opaque types for any additional properties.

    Return Value

    The value for property in record. The type of the returned value depends on the property type (see Property Types for a list of possible property types). You are responsible for releasing this object.

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

  • Sets the value of a given property for a record.

    Declaration

    Swift

    func ABRecordSetValue(_ record: ABRecordRef, _ property: CFString!, _ value: AnyObject!) -> Bool

    Objective-C

    bool ABRecordSetValue ( ABRecordRef record, CFStringRef property, CFTypeRef value );

    Parameters

    record

    The record you wish to modify.

    property

    The property whose value you wish to set. May be a pre-defined or program-defined property. See Common Properties for a list of properties all records have, and specific ABRecord derived opaque types for any additional properties. If NULL, this function raises an exception.

    value

    The new value for property in record. If NULL or not the correct type, this function raises an exception.

    Return Value

    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 false. Returns true if successful, false otherwise.

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

Data Types

  • A reference to an ABRecord object or any of its derived opaque types.

    Declaration

    Swift

    typealias ABRecordRef = UnsafeMutablePointer<Void>

    Objective-C

    typedef void *ABRecordRef;

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

Constants

  • Properties common to all record types.

    Declaration

    Swift

    let kABUIDProperty: String let kABCreationDateProperty: String let kABModificationDateProperty: String

    Objective-C

    CFStringRef kABUIDProperty; CFStringRef kABCreationDateProperty; CFStringRef kABModificationDateProperty

    Constants

    • kABUIDProperty

      kABUIDProperty

      The UID property.

      Available in OS X v10.2 and later.

    • kABCreationDateProperty

      kABCreationDateProperty

      Creation date (when first saved).

      Available in OS X v10.2 and later.

    • kABModificationDateProperty

      kABModificationDateProperty

      Modification date (when last saved).

      Available in OS X v10.2 and later.