< Previous PageNext Page > Hide TOC

Counted Sets: Unordered Collection of Indistinct Objects

NSCountedSet, a subclass of NSMutableSet, is a set to which you can add a particular object more than once; in other words, the elements of the set aren’t necessarily distinct. A counted set is also known as a bag. The NSCountedSet class is available only in Objective-C.

Each distinct object inserted into an NSCountedSet object has a counter associated with it. NSCountedSet keeps track of the number of times objects are inserted and requires that objects be removed the same number of times. Thus, there is only one instance of an object in an NSCountedSet even if the object has been added to the set multiple times. The countForObject: method returns the number of times the specified object has been added to this set.



< Previous PageNext Page > Hide TOC


© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-02-04)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.