Is it possible that there are several categories in the NSR variable? Some NSRange = [NSMakeRange (0, 2), NSMakeRange (10, 1), ...]
or or may not be the ranges? Yes, Specify all indexes: Calculate all the boundaries: test subscription: but note that
Is there another varaible type for more than one category?
Ns (convertible) IndexSet stores a collection of unsigned integers in the form of sequence of Indexes (unique) dates. Example: Create a variable index set and add both series and one index:
Go to indexSet = NSMutableIndexSet () indexSet.addIndexesInRange (NSMakeRange (0, 2) indexSet .addIndexesInRange (NSMakeRange (10, 3) indexSet.addIndex (5) println (indexSet) // & LT; NSMutableIndexSet: 0x10050a510 & gt; [Number of indexes: 6 (ranges in 3), indexed: (0-1 5 10-12)]
IndexSet.enumerateIndexesUsingBlock {(index, stop) - & gt; Zero (index) in println // output: 0 to 5 to 10 11 12
indexSet.enumerateRangesUsingBlock {( Range, stop) - & gt; Println in zero (range)} // output: (0,2) (5,1) (10,3)
If indexSet.containsIndex (11) {// ...}
NSIndexSet
represent the group , i.e. There are no duplicate elements, and the sequence of elements does not matter, it may or may not be useful depending on your needs. Example:
Go to indexSet = NSMutableIndexSet () indexSet.addIndexesInRange (NSMakeRange (0, 4)) indexSet.addIndexesInRange (NSMakeRange (2, 4)) indexSet.enumerateRangesUsingBlock {(range, off Cry) - & gt; Zero (range)} / output in println: (0,6)
Comments
Post a Comment