1

I have an array of objects in a tableView. I want the user to be able to go to another page and select from a checklist of objects to filter the first array.

How should I handle the data from the checklist? I am currently handling it as an NSMutableArray of selected objects. But then how do I filter the first array with the contents of another array?

Should I handle each item as a NSString instead?

Thanks for the help!

1
  • Oops. I corrected a mistake in the title. Hopefully that clears up any confusion. Commented Oct 31, 2009 at 21:14

3 Answers 3

1

I would rather use a NSMutableDictionary instead of the second array, associating each object (the key) a value that tells me if it has been selected or not. This way, verifying the selected settings would be faster when I inspect the first array (the one that needs to be filtered).

Sign up to request clarification or add additional context in comments.

Comments

1

If your objects implement isEquals:\hash, you can use an NSSet to store the selected objects. Then you can do a set lookup to see if they were selected. You should be able to construct a NSPredicate and filter the array using that.

Comments

1

If possible use NSMutableSets and just use the intersection.

Removes from the receiver each object that isn’t a member of another given set.

- (void)intersectSet:(NSSet *)otherSet

You can create the sets with:

  • (id)setWithArray:(NSArray *)anArray

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.