DekGenius.com
[ Team LiB ] Previous Section Next Section

NSMutableSet Mac OS X 10.0

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.

figs/cocn_1362.gif

@interface NSMutableSet : NSSet
 // Initializers
   - (id)initWithCapacity:(unsigned)numItems;
 // Accessor Methods
   - (void)setSet:(NSSet *)otherSet;
 // Class Methods
   + (id)setWithCapacity:(unsigned)numItems;
 // Instance Methods
   - (void)addObject:(id)object;
   - (void)addObjectsFromArray:(NSArray *)array;
   - (void)intersectSet:(NSSet *)otherSet;
   - (void)minusSet:(NSSet *)otherSet;
   - (void)removeAllObjects;
   - (void)removeObject:(id)object;
   - (void)unionSet:(NSSet *)otherSet;

Subclasses

NSCountedSet

    [ Team LiB ] Previous Section Next Section