nsindexset

Fast enumeration on an NSIndexSet

大兔子大兔子 提交于 2019-11-27 13:26:34
问题 Can you fast enumerate a NSIndexSet ? if not, what's the best way to enumerate the items in the set? 回答1: Fast enumeration must yield objects; since an NSIndexSet contains scalar numbers ( NSUInteger s), not objects, no, you cannot fast-enumerate an index set. Hypothetically, it could box them up into NSNumbers, but then it wouldn't be very fast. 回答2: In OS X 10.6+ and iOS SDK 4.0+, you can use the -enumerateIndexesUsingBlock: message: NSIndexSet *idxSet = ... [idxSet