BluGeni
BluGeni

Reputation: 3454

how do I access the data of a NSMutableIndexSet

I have a NSMutableIndexSet of:

<NSMutableIndexSet: 0x85825c0>[number of indexes: 2 (in 2 ranges), indexes: (2 4)]

How do I set the number of indexes (2) to a property like an int and indexes to an array (2 4)

Upvotes: 0

Views: 1137

Answers (1)

Martin R
Martin R

Reputation: 540145

You can use the count method to get the number of indexes in the set. With enumerateIndexesUsingBlock: you can enumerate all indexes in the set and add them to an NSMutableArray:

NSUInteger numberOfIndexes = [set count];
NSMutableArray *array = [NSMutableArray array];
[set enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
    [array addObject:@(idx)];
}];
NSLog(@"%@", array);

Upvotes: 2

Related Questions