views:

919

answers:

2

What's the difference?

In my context, I need to be able to dynamically add to and remove objects. The user clicks on rows of a table that check on and off and thus add or remove the referenced object from the list.

A wild guess is that array has indexed items while set has no indexes?

+5  A: 

An NSSet/NSMutableSet doesn't keep items in any particular order. An NSArray/NSMutableArray does store the items in a particular order. If you're building a table view, you should definitely use an array as your data source of choice.

Alex
+2  A: 

Also, NSMutableSet makes sure that all objects are unique.

NSMutableArray goes well with UITableView since elements have index, so you can return [array count] to get number of table rows, or [array objectAtIndex:rowNumber] to easily associate element with row.

Rudi
This is something I didn't realize
Brenden