iOS Reference Library Apple Developer
Search

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.




Last updated: 2010-07-08

Did this document help you? Yes It's good, but... Not helpful...