iOS Developer Library

Developer

AddressBook Framework Reference ABRecord Reference

Options
Deployment Target:

On This Page
Language:

ABRecord Reference

The ABRecord opaque type (whose objects are known as records) provides a common interface to the records in the Address Book database. It defines common properties for all records. A property is a field in a record such as the first or last name of a person record.

Each record in the Address Book database has a unique ID, which you obtain using the ABRecordGetRecordID function.

Functions

  • Sets the value of a record property.

    Declaration

    Swift

    func ABRecordSetValue(_ record: ABRecord!, _ property: ABPropertyID, _ value: AnyObject!, _ error: UnsafeMutablePointer<Unmanaged<CFError>?>) -> Bool

    Objective-C

    bool ABRecordSetValue ( ABRecordRef record, ABPropertyID property, CFTypeRef value, CFErrorRef *error );

    Parameters

    record

    The record containing the property in question.

    property

    The property whose value is being set. See properties in Constants in ABPerson Reference and Constants.

    value

    The new value. Pass NULL to remove the property from record.

    error

    On failure, information about its cause.

    Return Value

    true when successful, false otherwise.

    Import Statement

    import AddressBook

    Availability

    Available in iOS 2.0 and later.

  • Returns the value of a record property.

    Declaration

    Swift

    func ABRecordCopyValue(_ record: ABRecord!, _ property: ABPropertyID) -> Unmanaged<AnyObject>!

    Objective-C

    CFTypeRef ABRecordCopyValue ( ABRecordRef record, ABPropertyID property );

    Parameters

    record

    The record containing the property in question.

    property

    The property of record whose value is being returned. See properties in Constants in ABPerson Reference and Constants.

    Return Value

    The value of property in record.

    Import Statement

    import AddressBook

    Availability

    Available in iOS 2.0 and later.

  • Removes the value of a record property.

    Declaration

    Swift

    func ABRecordRemoveValue(_ record: ABRecord!, _ property: ABPropertyID, _ error: UnsafeMutablePointer<Unmanaged<CFError>?>) -> Bool

    Objective-C

    bool ABRecordRemoveValue ( ABRecordRef record, ABPropertyID property, CFErrorRef *error );

    Parameters

    record

    The record with the property in question.

    property

    The property, in record, whose value is being removed. See properties in Constants in ABPerson Reference and Constants.

    error

    On failure, information about its cause.

    Return Value

    true on success, false otherwise.

    Import Statement

    import AddressBook

    Availability

    Available in iOS 2.0 and later.

  • Returns an appropriate, human-friendly name for the record.

    Declaration

    Swift

    func ABRecordCopyCompositeName(_ record: ABRecord!) -> Unmanaged<CFString>!

    Objective-C

    CFStringRef ABRecordCopyCompositeName ( ABRecordRef record );

    Parameters

    record

    The record whose name is being returned.

    Return Value

    • For person records: The concatenated value of these properties: Prefix, Suffix, Organization, First name, and Last name.

    • For group records: The value of the group name property (kABGroupNameProperty).

    Discussion

    The behavior of this function is not defined for source records.

    Import Statement

    import AddressBook

    Availability

    Available in iOS 2.0 and later.

Data Types

  • Reference to a record.

    Declaration

    Swift

    typealias ABRecordRef = ABRecord

    Objective-C

    typedef CFTypeRef ABRecordRef;

    Import Statement

    import AddressBook

    Availability

    Available in iOS 2.0 and later.

  • Integer that identifies a record.

    Declaration

    Swift

    typealias ABRecordID = Int32

    Objective-C

    typedef int32_t ABRecordID;

    Discussion

    Valid record IDs are positive integers.

    See “Invalid Record ID”.

    Import Statement

    import AddressBook

    Availability

    Available in iOS 2.0 and later.

  • Integer that identifies a record property.

    Declaration

    Swift

    typealias ABPropertyID = Int32

    Objective-C

    typedef int32_t ABPropertyID;

    Discussion

    See properties listed in Constants in ABPerson Reference and Constants

    Import Statement

    import AddressBook

    Availability

    Available in iOS 2.0 and later.

  • Integer that identifies a record type.

    Declaration

    Swift

    typealias ABRecordType = UInt32

    Objective-C

    typedef uint32_t ABRecordType;

    Discussion

    See “Record Types”.

    Import Statement

    import AddressBook

    Availability

    Available in iOS 2.0 and later.

  • Integer that identifies a record property type.

    Declaration

    Swift

    typealias ABPropertyType = UInt32

    Objective-C

    typedef uint16_t ABPropertyType;

    Discussion

    See “Record Property Types”.

    Import Statement

    import AddressBook

    Availability

    Available in iOS 2.0 and later.

Constants

  • These constants identify record types.

    Declaration

    Swift

    var kABPersonType: Int { get } var kABGroupType: Int { get } var kABSourceType: Int { get }

    Objective-C

    enum { kABPersonType = 0, kABGroupType = 1, kABSourceType = 2 };

    Constants

    • kABPersonType

      kABPersonType

      Person record.

      Available in iOS 2.0 and later.

    • kABGroupType

      kABGroupType

      Group record.

      Available in iOS 2.0 and later.

    • kABSourceType

      kABSourceType

      Source record.

      Available in iOS 5.0 and later.

    Discussion

    See ABRecordType.

    Import Statement

  • Indicates a multivalue property.

    Declaration

    Swift

    var kABMultiValueMask: Int32 { get }

    Objective-C

    #define kABMultiValueMask (1 << 8)

    Constants

    • kABMultiValueMask

      kABMultiValueMask

      Indicates a multivalue property.

      Available in iOS 2.0 and later.

    Import Statement

  • These constants identify record property types.

    Declaration

    Swift

    var kABInvalidPropertyType: Int { get } var kABStringPropertyType: Int { get } var kABIntegerPropertyType: Int { get } var kABRealPropertyType: Int { get } var kABDateTimePropertyType: Int { get } var kABDictionaryPropertyType: Int { get } var kABMultiStringPropertyType: Int { get } var kABMultiIntegerPropertyType: Int { get } var kABMultiRealPropertyType: Int { get } var kABMultiDateTimePropertyType: Int { get } var kABMultiDictionaryPropertyType: Int { get }

    Objective-C

    enum { kABInvalidPropertyType = 0x0, kABStringPropertyType = 0x1, kABIntegerPropertyType = 0x2, kABRealPropertyType = 0x3, kABDateTimePropertyType = 0x4, kABDictionaryPropertyType = 0x5, kABMultiStringPropertyType = kABMultiValueMask | kABStringPropertyType kABMultiIntegerPropertyType = kABMultiValueMask | kABIntegerPropertyType kABMultiRealPropertyType = kABMultiValueMask | kABRealPropertyType kABMultiDateTimePropertyType = kABMultiValueMask | kABDateTimePropertyType kABMultiDictionaryPropertyType = kABMultiValueMask | kABDictionaryPropertyType };

    Constants

    • kABInvalidPropertyType

      kABInvalidPropertyType

      Invalid property.

      Available in iOS 2.0 and later.

    • kABStringPropertyType

      kABStringPropertyType

      String property. Returned as a CFStringRef object.

      Available in iOS 2.0 and later.

    • kABIntegerPropertyType

      kABIntegerPropertyType

      Integer property. Returned as a CFNumberRef object.

      Available in iOS 2.0 and later.

    • kABRealPropertyType

      kABRealPropertyType

      Real property. Returned as a CFNumberRef object.

      Available in iOS 2.0 and later.

    • kABDateTimePropertyType

      kABDateTimePropertyType

      Date-time property. Returned as a CFDateRef object.

      Available in iOS 2.0 and later.

    • kABDictionaryPropertyType

      kABDictionaryPropertyType

      Dictionary property. Returned as a CFDictionaryRef object.

      Available in iOS 2.0 and later.

    • kABMultiStringPropertyType

      kABMultiStringPropertyType

      Multistring property. Returned as an ABMultiValueRef of CFStringRef objects.

      Available in iOS 2.0 and later.

    • kABMultiIntegerPropertyType

      kABMultiIntegerPropertyType

      Multiinteger property. Returned as an ABMultiValueRef of CFNumberRef objects.

      Available in iOS 2.0 and later.

    • kABMultiRealPropertyType

      kABMultiRealPropertyType

      Multireal property. Returned as an ABMultiValueRef of CFNumberRef objects.

      Available in iOS 2.0 and later.

    • kABMultiDateTimePropertyType

      kABMultiDateTimePropertyType

      Multi–date-time property. Returned as an ABMultiValueRef of CFDateRef objects.

      Available in iOS 2.0 and later.

    • kABMultiDictionaryPropertyType

      kABMultiDictionaryPropertyType

      Multidictionary property. Returned as an ABMultiValueRef of CFDictionaryRef objects.

      Available in iOS 2.0 and later.

    Discussion

    See ABPropertyType.

    Import Statement

  • These macros identify invalid values for record and property identifiers.

    Declaration

    Swift

    var kABRecordInvalidID: Int32 { get } var kABPropertyInvalidID: Int32 { get }

    Objective-C

    #define kABRecordInvalidID -1 #define kABPropertyInvalidID -1

    Constants

    • kABRecordInvalidID

      kABRecordInvalidID

      Records with this ID have not been saved to the Address Book database.

      Available in iOS 2.0 and later.

    • kABPropertyInvalidID

      kABPropertyInvalidID

      Indicates an invalid value for a property ID.

      Available in iOS 3.0 and later.

    Import Statement