Mac Developer Library

Developer

AddressBook Framework Reference ABMutableMultiValue Class Reference

Options
Deployment Target:

On This Page
Language:

ABMutableMultiValue

The ABMultiValue and ABMutableMultiValue classes are used to represent properties that might have multiple values. Each value in a multivalue list must be of the same type, and must have an associated predefined or user-defined label, and unique identifier. The labels, however, need not be unique. For example, you can have multiple Home phone numbers. Each multivalue object may have a primary identifier—used as a default value when a label is not provided. For example, a person record may have multiple addresses with the labels Home and Work, where Work is designated as the primary value. Instances of ABMutableMultiValue are mutable, see ABMultiValue for additional methods that access the content of a multivalue list. More...

Inheritance


Import Statement


import AddressBook @import AddressBook;

Availability


Available in OS X v10.2 and later.
  • Adds a value and its label to a multivalue list.

    Declaration

    Swift

    func addValue(_ value: AnyObject!, withLabel label: String!) -> String!

    Objective-C

    - (NSString *)addValue:(id)value withLabel:(NSString *)label

    Parameters

    value

    The value to add.

    label

    The label to associate with the value.

    Return Value

    The new identifier if value is added successfully; otherwise, nil.

    Discussion

    The value argument must be of the correct type. For example, if the receiver is the value for a property of type kABMultiStringProperty, then value needs to be an NSString object. See Property Types for a list of supported types in a multivalue list (see descriptions of the kABMulti... constants). If either the value or the label argument is nil, this method raises an exception.

    This method performs no type checking and will let you add a value whose type does not match the types of the other values in the list. However, if you try to use a multivalue list whose values are not all of the same type, other methods, such as the ABRecord setValue:forProperty: method, will return NOfalse or kABErrorInProperty.

    Import Statement

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

  • Inserts a value and its label at the given index in a multivalue list.

    Declaration

    Swift

    func insertValue(_ value: AnyObject!, withLabel label: String!, atIndex index: Int) -> String!

    Objective-C

    - (NSString *)insertValue:(id)value withLabel:(NSString *)label atIndex:(NSUInteger)index

    Parameters

    value

    The value to add.

    label

    The label to associate with the value.

    index

    The index where the value will be inserted.

    Return Value

    The identifier of the inserted value and label if they are added successfully; otherwise, nil.

    Discussion

    If either the value or the label is nil or if the index is out of bounds, this method raises an exception

    This method performs no type checking and will let you add a value whose type does not match the types of the other values in the list. However, if you try to use a multivalue list whose values are not all of the same type, other methods, such as the ABRecord setValue:forProperty: method, will return NOfalse or kABErrorInProperty.

    Import Statement

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

  • Replaces the label at the given index.

    Declaration

    Swift

    func replaceLabelAtIndex(_ index: Int, withLabel label: String!) -> Bool

    Objective-C

    - (BOOL)replaceLabelAtIndex:(NSUInteger)index withLabel:(NSString *)label

    Parameters

    index

    The index of the label that will be replaced.

    label

    The new label.

    Return Value

    YEStrue if successful; otherwise, NOfalse.

    Discussion

    If the label is nil or if the index is out of bounds, this method raises an exception.

    Import Statement

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

  • Replaces the value at the given index.

    Declaration

    Swift

    func replaceValueAtIndex(_ index: Int, withValue value: AnyObject!) -> Bool

    Objective-C

    - (BOOL)replaceValueAtIndex:(NSUInteger)index withValue:(id)value

    Parameters

    index

    The index of the value that will be replaced.

    value

    The new value.

    Return Value

    YEStrue if successful; otherwise NOfalse.

    Discussion

    If the value is nil or if the index is out of bounds, this method raises an exception.

    Import Statement

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

  • Removes the value and label at the given index.

    Declaration

    Swift

    func removeValueAndLabelAtIndex(_ index: Int) -> Bool

    Objective-C

    - (BOOL)removeValueAndLabelAtIndex:(NSUInteger)index

    Parameters

    index

    The index of the value-label pair that will be removed.

    Return Value

    YEStrue if successful; otherwise NOfalse.

    Discussion

    If the index is out of bounds, this method raises an exception.

    Import Statement

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

  • Sets the primary value to be the value for the given identifier.

    Declaration

    Swift

    func setPrimaryIdentifier(_ identifier: String!) -> Bool

    Objective-C

    - (BOOL)setPrimaryIdentifier:(NSString *)identifier

    Parameters

    identifier

    The identifier whose value will be used as the primary value for a multivalue property.

    Return Value

    YEStrue if successful; otherwise NOfalse.

    Discussion

    If the identifier is nil, this method raises an exception. Use the identifierAtIndex: method to get the identifier given the index.

    Import Statement

    import AddressBook

    Availability

    Available in OS X v10.2 and later.

    See Also

    – primaryIdentifier (ABMultiValue)