Name
NSCountedSet — Mac OS X 10.0
Synopsis
This class extends the functionality of
NSMutableSet
by associating with each member of
the set a count of how many times the object has been added to the
set. By keeping a count with each object,
NSCountedSet
essentially removes the restriction
that every member of a set must be unique.
NSCountedSet
reimplements several of
NSMutableSet
’s methods to support
the object counter. The one new method in
NSCountedSet
is
countForObject
:, which will return the counter
value for the specified object. If the object is not a member of the
set, this method returns 0
. This count can be
viewed as the number of occurences of the object within the set.
|
@interface NSCountedSet : NSMutableSet
|
// Initializers
|
- (id)initWithArray:(NSArray *)array; |
- (id)initWithCapacity:(unsigned)numItems; |
- (id)initWithSet:(NSSet *)set; |
// Instance Methods
|
- (void)addObject:(id)object; |
- (unsigned)countForObject:(id)object; |
- (NSEnumerator *)objectEnumerator;
|
- (void)removeObject:(id)object; |
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.