I’m getting the select items from a table view with:
NSIndexSet *selectedItems = [aTableView selectedRowIndexes];
what’s the best way to get the indexes in a NSArray object?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Enumerate the set, make NSNumbers out of the indexes, add the NSNumbers to an array.
That’s how you’d do it. I’m not sure I see the point in transforming a set of indexes into a less efficient representation, though.
To enumerate a set, you have two options. If you’re targeting OS X 10.6 or iOS 4, you can use
enumerateIndexesUsingBlock:. If you’re targeting earlier versions, you’ll have to get thefirstIndexand then keep asking forindexGreaterThanIndex:on the previous result until you getNSNotFound.