NSIndexSet
Let’s take a look at another type of set: the NSIndexSet. This class is used to store ordered indexes into some other data structure, typically an array. You can use this class, for example, to efficiently generate a list of index numbers from an array of objects, where each object satisfies some criteria that you specify. Note that there is no mutable version of the NSIndexSet class.
For example, the NSArray method indexOfObjectPassingTest: takes a block as its argument. The block gets executed for each element in the array, passing in the array element, the index number, and a pointer to a BOOL variable. The code in the block will presumably test the element against some criteria and return YES if the array element satisfies the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access