Name

NSMutableSet — Mac OS X 10.0

Synopsis

This class extends the functionality of NSSet by allowing objects to be added to and removed from the set; NSSet does not allow clients to add, remove, or replace objects in a set after initialization. This mutable subclass of NSSet provides an interface for those operations.

To add an object to a mutable set, use the method addObject:. If the object is already present in the set, this method has no effect. When an object is added to a set, it is sent a retain message by that set. The method removeObject: will remove the specified object from the set if it is a member. When an object is removed from a set, it is sent a release message by the set to counteract the retain message it was sent when added to the set.

NSMutableSet also implements a number of methods that are useful for combining sets in various ways. The method unionSet: will add each member of the parameter set into the receiver if the receiver does not already contain that object. The method minusSet: will remove from the receiver each object that is present in both sets, while the method intersectSet: will remove from the receiver each object that isn’t a member of the set specified in the argument.

NSMutableSet is toll-free bridged with the Core Foundation type CFSet. As such, NSMutableSet objects can be used interchangeably with the CFSet pointer type, CFSetRef.

image with no caption

@interface ...

Get Cocoa in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.