Mac Developer Library

Developer

AddressBook Framework Reference ABGroup Class Reference

Options
Deployment Target:

On This Page
Language:

ABGroup

Inheritance


Conforms To


Import Statement


Swift

import AddressBook

Objective-C

@import AddressBook;

Availability


Available in OS X v10.2 and later.

The ABGroup class supports the concept of a “group” containing one or more persons. People may belong to multiple groups, and groups may also belong to other groups unless the relationship causes a circular reference. The only predefined property of a group is its name. However, similar to person records, you can add your own properties to group records. Groups not only help to organize person records, but also allow you to create email distribution lists.

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

  • Adds the given properties to all 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 be added and their types.

    Return Value

    The number of properties successfully added.

    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.groupID. 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 the properties to be removed.

    Return Value

    The number of properties successfully removed.

    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 this record type 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 for 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.

    Return Value

    The property type of property.

    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

  • Adds a person to a group.

    Declaration

    Swift

    func addMember(_ person: ABPerson!) -> Bool

    Objective-C

    - (BOOL)addMember:(ABPerson *)person

    Parameters

    person

    The person record to be added.

    Return Value

    YEStrue if successful; otherwise, NOfalse.

    Discussion

    If the person argument is already part of the group, this method does nothing and returns YEStrue. If the person argument is nil, this method raises an exception.

    Special Considerations

    Prior to OS X v10.6, if the person record is already in the group, this method does nothing and returns NOfalse.

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

  • Removes a person from a group.

    Declaration

    Swift

    func removeMember(_ person: ABPerson!) -> Bool

    Objective-C

    - (BOOL)removeMember:(ABPerson *)person

    Parameters

    person

    The person to be removed.

    Return Value

    YEStrue if successful; otherwise, NOfalse.

    Discussion

    If the person argument is not in the group, this method does nothing and returns NOfalse. If person is nil, this method raises an exception.

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

  • Returns an array of persons in a group.

    Declaration

    Swift

    func members() -> [AnyObject]!

    Objective-C

    - (NSArray *)members

    Discussion

    If this group doesn’t contain any people, this method returns an empty array.

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

  • Adds a subgroup to another group.

    Declaration

    Swift

    func addSubgroup(_ group: ABGroup!) -> Bool

    Objective-C

    - (BOOL)addSubgroup:(ABGroup *)group

    Parameters

    group

    The group to add as a subgroup.

    Return Value

    YEStrue if successful; otherwise, NOfalse.

    Discussion

    If the group argument is already part of the receiver, this method does nothing and returns NOfalse. If adding the group would create a recursion, this method also does nothing and returns NOfalse. (For example, if the group Animal Lovers is in Dog Lovers, and you add Dog Lovers to Animal Lovers, that would create a recursion, which this method won’t allow.) If the group argument is nil, this method raises an exception.

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

  • Removes a subgroup from a group.

    Declaration

    Swift

    func removeSubgroup(_ group: ABGroup!) -> Bool

    Objective-C

    - (BOOL)removeSubgroup:(ABGroup *)group

    Parameters

    group

    The subgroup to be removed.

    Return Value

    YEStrue if successful; otherwise, NOfalse.

    Discussion

    If the group argument is not a subgroup, this method does nothing and returns NOfalse. If group is nil, this method raises an exception.

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

  • Returns an array containing a group’s parents—that is, the groups that a group belongs to.

    Declaration

    Swift

    func parentGroups() -> [AnyObject]!

    Objective-C

    - (NSArray *)parentGroups

    Discussion

    If this group 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.

    See Also

    – subgroups

  • Returns an array containing a group’s subgroups.

    Declaration

    Swift

    func subgroups() -> [AnyObject]!

    Objective-C

    - (NSArray *)subgroups

    Discussion

    If this group doesn’t contain 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 the distribution identifier for the given property and person.

    Declaration

    Swift

    func distributionIdentifierForProperty(_ property: String!, person person: ABPerson!) -> String!

    Objective-C

    - (NSString *)distributionIdentifierForProperty:(NSString *)property person:(ABPerson *)person

    Parameters

    property

    The property whose distribution identifier will be returned.

    person

    The person whose distribution identifier will be returned.

    Return Value

    The distribution identifier for the given property and person.

    Discussion

    If a distribution identifier is not set, this method returns the multivalue’s primary identifier. If either the property or the person argument is nil, this method returns nil. This method also returns nil if property is not a multivalue list property, or if person is not a member of the group.

    Distribution identifiers let you use groups as distribution lists, by indicating which value in a multivalue property should be used when addressing the group. See Using Address Book Groups as Distribution Lists for more detailed discussion.

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

  • Assigns a specific distribution identifier for a person’s multivalue list property so that the group can be used as a distribution list.

    Declaration

    Swift

    func setDistributionIdentifier(_ identifier: String!, forProperty property: String!, person person: ABPerson!) -> Bool

    Objective-C

    - (BOOL)setDistributionIdentifier:(NSString *)identifier forProperty:(NSString *)property person:(ABPerson *)person

    Parameters

    identifier

    The identifier to be set as the distribution identifier

    property

    The property whose distribution identifier will be set.

    person

    The person whose distribution identifier will be.

    Return Value

    YEStrue if successful; otherwise, NOfalse.

    Discussion

    The default distribution identifier is a multivalue list’s primary identifier. If person is nil, this method raises an exception.

    Distribution identifiers let you use groups as distribution lists, by indicating which value in a multivalue property should be used when addressing the group. See Using Address Book Groups as Distribution Lists for more detailed discussion.

    Import Statement

    Objective-C

    @import AddressBook;

    Swift

    import AddressBook

    Availability

    Available in OS X v10.2 and later.