iOS Developer Library

Developer

Foundation Framework Reference NSMutableOrderedSet Class Reference

Options
Deployment Target:

On This Page
Language:

NSMutableOrderedSet

NSMutableOrderedSet class declares the programmatic interface to a mutable, ordered collection of distinct objects.

NSMutableOrderedSet objects are not like C arrays. That is, even though you may specify a size when you create a mutable ordered set, the specified size is regarded as a “hint”; the actual size of the set is still 0. This means that you cannot insert an object at an index greater than the current count of an set. For example, if a set contains two objects, its size is 2, so you can add objects at indices 0, 1, or 2. Index 3 is illegal and out of bounds; if you try to add an object at index 3 (when the size of the array is 2), NSMutableOrderedSet raises an exception.

  • Creates and returns an mutable ordered set with a given initial capacity.

    Declaration

    Objective-C

    + (instancetype)orderedSetWithCapacity:(NSUInteger)numItems

    Parameters

    numItems

    The initial capacity of the new ordered set.

    Return Value

    A mutable ordered set with initial capacity to hold numItems members.

    Discussion

    Mutable ordered sets allocate additional memory as needed, so numItems simply establishes the set’s initial capacity.

    Availability

    Available in iOS 5.0 and later.

  • Returns an initialized mutable ordered set with a given initial capacity.

    Declaration

    Swift

    init(capacity numItems: Int)

    Objective-C

    - (instancetype)initWithCapacity:(NSUInteger)numItems

    Parameters

    numItems

    The initial capacity of the new ordered set.

    Return Value

    An initialized mutable ordered set with initial capacity to hold numItems members.

    Discussion

    Mutable ordered sets allocate additional memory as needed, so numItems simply establishes the set’s initial capacity.

    This method is a designated initializer of NSMutableOrderedSet.

    Availability

    Available in iOS 5.0 and later.

  • init() - init Designated Initializer

    Initializes a newly allocated mutable ordered set.

    Declaration

    Swift

    init()

    Objective-C

    - (instancetype)init

    Return Value

    A mutable ordered set.

    Discussion

    This method is a designated initializer of NSMutableOrderedSet.

    Availability

    Available in iOS 7.0 and later.

  • Removes from the receiving ordered set each object that isn’t a member of another ordered set.

    Declaration

    Swift

    func intersectOrderedSet(_ other: NSOrderedSet)

    Objective-C

    - (void)intersectOrderedSet:(NSOrderedSet<ObjectType> *)other

    Parameters

    other

    The ordered set with which to perform the intersection.

    Availability

    Available in iOS 5.0 and later.

  • Removes from the receiving ordered set each object that isn’t a member of another set.

    Declaration

    Swift

    func intersectSet(_ other: Set<NSObject>)

    Objective-C

    - (void)intersectSet:(NSSet<ObjectType> *)other

    Parameters

    other

    The set with which to perform the intersection.

    Availability

    Available in iOS 5.0 and later.

  • Removes each object in another given ordered set from the receiving mutable ordered set, if present.

    Declaration

    Swift

    func minusOrderedSet(_ other: NSOrderedSet)

    Objective-C

    - (void)minusOrderedSet:(NSOrderedSet<ObjectType> *)other

    Parameters

    other

    The ordered set of objects to remove from the receiving set.

    Availability

    Available in iOS 5.0 and later.

    See Also

    – minusSet:

  • Removes each object in another given set from the receiving mutable ordered set, if present.

    Declaration

    Swift

    func minusSet(_ other: Set<NSObject>)

    Objective-C

    - (void)minusSet:(NSSet<ObjectType> *)other

    Parameters

    other

    The set of objects to remove from the receiving set.

    Availability

    Available in iOS 5.0 and later.

  • Adds each object in another given ordered set to the receiving mutable ordered set, if not present.

    Declaration

    Swift

    func unionOrderedSet(_ other: NSOrderedSet)

    Objective-C

    - (void)unionOrderedSet:(NSOrderedSet<ObjectType> *)other

    Parameters

    other

    The set of objects to add to the receiving mutable ordered set.

    Availability

    Available in iOS 5.0 and later.

    See Also

    – unionSet:

  • Adds each object in another given set to the receiving mutable ordered set, if not present.

    Declaration

    Swift

    func unionSet(_ other: Set<NSObject>)

    Objective-C

    - (void)unionSet:(NSSet<ObjectType> *)other

    Parameters

    other

    The set of objects to add to the receiving mutable ordered set.

    Availability

    Available in iOS 5.0 and later.