NSIndexSet
NSIndexSet (like its mutable counterpart, NSMutableIndexSet) is a sorted collection of unique unsigned integers. Think of it like an NSRange that supports non-contiguous series. It has wicked fast operations for finding indexes in ranges or set intersections, and comes with all of the convenience methods you’d expect in a Foundation collection class.
NSIndexSet and its mutable version, NSMutableIndexSet, form a sorted set of unique unsigned integers. They act like an NSRange that allows gaps. They offer quick checks for indices in ranges or overlaps, plus standard Foundation collection methods.
You see NSIndexSet in Foundation when methods fetch several items from sorted groups, such as arrays or table view sources.
It fits some data models well. For instance, AFNetworking uses it for HTTP status codes: users set acceptable ones, and responses are checked with containsIndex:.
In Swift, PermutationGenerator pairs with NSIndexSet to loop through chosen indices in a collection.
Ideas: Use it with enums to track active user settings. Or filter items by storing indices per rule, then combine with union or intersection as rules change.
NSIndexSet is reliable, if specialised. It shows the useful tools in Foundation's own interfaces.
Category:
Tags:
Year: