Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fast enumeration on an NSIndexSet

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

like image 200
cfischer Avatar asked Nov 17 '10 20:11

cfischer


1 Answers

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 }]; 
like image 146
Barry Wark Avatar answered Oct 03 '22 14:10

Barry Wark