O'Reilly logo

Cocoa in a Nutshell by James Duncan Davidson, Michael Beam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required