Fast enumeration on an NSIndexSet

后端 未结 6 729
南旧
南旧 2020-12-14 14:13

Can you fast enumerate a NSIndexSet? if not, what\'s the best way to enumerate the items in the set?

6条回答
  •  情深已故
    2020-12-14 14:51

    In OS X 10.6+ and iOS SDK 4.0+, you can use the -enumerateIndexesUsingBlock: message:

    NSIndexSet *idxSet = ...
    
    [idxSet enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
      //... do something with idx
      // *stop = YES; to stop iteration early
    }];
    

提交回复
热议问题