Mac Developer Library

Developer

AddressBook Framework Reference ABPerson Class Reference

Options
Deployment Target:

On This Page
Language:

ABPerson

Inheritance


Conforms To


Import Statement


Swift

import AddressBook

Objective-C

@import AddressBook;

Availability


Available in OS X v10.2 and later.

The ABPerson class encapsulates all information about a person in the Address Book database—an instance of ABPerson corresponds to a single person record in the database. The ABPerson class defines properties such as the person’s name, company, address, email addresses, and phone numbers.

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

  • Adds the given properties to all the records of this type in the Address Book database.

    Declaration

    Swift

    class func addPropertiesAndTypes(_ properties: [NSObject : AnyObject]!) -> Int

    Objective-C

    + (NSInteger)addPropertiesAndTypes:(NSDictionary *)properties

    Parameters

    properties

    A dictionary of properties to add, and their types.

    Return Value

    The number of properties successfully added, or -1 if an error occurs.

    Discussion

    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.

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

  • Removes the given properties from all the records of this type in the Address Book database.

    Declaration

    Swift

    class func removeProperties(_ properties: [AnyObject]!) -> Int

    Objective-C

    + (NSInteger)removeProperties:(NSArray *)properties

    Parameters

    properties

    An array of properties to remove.

    Return Value

    The number of properties successfully removed, or -1 if an error occurs.

    Discussion

    Only custom properties can be removed. This method is not implemented.

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

  • Returns an array of the names of all the properties for the record in the Address Book database.

    Declaration

    Swift

    class func properties() -> [AnyObject]!

    Objective-C

    + (NSArray *)properties

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

  • Returns the type of a given property.

    Declaration

    Swift

    class func typeOfProperty(_ property: String!) -> ABPropertyType

    Objective-C

    + (ABPropertyType)typeOfProperty:(NSString *)property

    Parameters

    property

    The property whose type will be returned.

    Discussion

    If the property does not exist, this method returns kABErrorInProperty.

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

    See Also

    + properties

  • Returns the array of all person records that are linked to the person this record represents.

    Declaration

    Swift

    func linkedPeople() -> [AnyObject]!

    Objective-C

    - (NSArray *)linkedPeople

    Return Value

    The array of all person records that are linked to the person this record represents.

    Discussion

    Linked records contain information about the same person, and typically come from different sources.

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.8 and later.

  • Returns an array of the address book groups that this person belongs to.

    Declaration

    Swift

    func parentGroups() -> [AnyObject]!

    Objective-C

    - (NSArray *)parentGroups

    Discussion

    If the person doesn’t belong to any groups, this method returns an empty array.

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

  • Returns an ABPerson instance initialized with the given data.

    Declaration

    Swift

    init!(VCardRepresentation vCardData: NSData!)

    Objective-C

    - (id)initWithVCardRepresentation:(NSData *)vCardData

    Parameters

    vCardData

    A data object containing a vCard representation of a person record.

    Return Value

    An ABPerson instance initialized with the given data.

    Discussion

    Version 2.1 and 3.0 of the vCard format are supported. If vCardData is nil or is not a valid vCard format, this method returns nil.

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

  • Returns the vCard representation of the person record as a data object in vCard format.

    Declaration

    Swift

    func vCardRepresentation() -> NSData!

    Objective-C

    - (NSData *)vCardRepresentation

    Return Value

    A data object containing the vCard representation of the person record.

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

  • Settings that determine how person records are displayed.

    Declaration

    Swift

    var kABShowAsMask: Int32 { get } var kABShowAsPerson: Int32 { get } var kABShowAsCompany: Int32 { get } var kABShowAsResource: Int32 { get } var kABShowAsRoom: Int32 { get } var kABNameOrderingMask: Int32 { get } var kABDefaultNameOrdering: Int32 { get } var kABFirstNameFirst: Int32 { get } var kABLastNameFirst: Int32 { get }

    Objective-C

    #define kABShowAsMask 000007 #define kABShowAsPerson 000000 #define kABShowAsCompany 000001 #define kABShowAsResource 000002 #define kABShowAsRoom 000003 #define kABNameOrderingMask 000070 #define kABDefaultNameOrdering 000000 #define kABFirstNameFirst 000040 #define kABLastNameFirst 000020

    Constants

    • kABShowAsMask

      kABShowAsMask

      Used in conjunction with kABShowAsPerson, kABShowAsCompany, kABShowAsResource, and kABShowAsRoom to determine record configuration.

      Available in OS X v10.3 and later.

    • kABShowAsPerson

      kABShowAsPerson

      Record is displayed as a person.

      Available in OS X v10.3 and later.

    • kABShowAsCompany

      kABShowAsCompany

      Record is displayed as a company.

      Available in OS X v10.3 and later.

    • kABShowAsResource

      kABShowAsResource

      Record is displayed as a resource.

      Available in OS X v10.6 and later.

    • kABShowAsRoom

      kABShowAsRoom

      Record is displayed as a room.

      Available in OS X v10.6 and later.

    • kABNameOrderingMask

      kABNameOrderingMask

      Used in conjunction with kABDefaultNameOrdering, kABFirstNameFirst, and kABLastNameFirst to determine name ordering.

      Available in OS X v10.3 and later.

    • kABDefaultNameOrdering

      kABDefaultNameOrdering

      Default name ordering (whether a person’s first name or last name is displayed first) the Address Book application.

      Available in OS X v10.3 and later.

    • kABFirstNameFirst

      kABFirstNameFirst

      First name is displayed first in Address Book.

      Available in OS X v10.3 and later.

    • kABLastNameFirst

      kABLastNameFirst

      Last name is displayed first in Address Book.

      Available in OS X v10.3 and later.