NSDictionary as a data structure for objects question
I just wanted to make sure I don't need Core Data for a simple example. If I have a UITableView where the user can hit the plus sign to add new table entri开发者_JAVA技巧es, and each entry corresponds to an individual timer event, do I store each object added to the table in an NSDictionary? Thanks.
NSMutableArray would be a better choice. An array is an ordered list, just as a table is. A dictionary is not ordered, so it's not a good match for a table.
If that's confusing, try thinking about it in concrete terms. Imagine that you have a table and you've stored the data for the table in a dictionary. At some point, the table will ask it's data source -- probably your view controller -- to provide a cell for a particular row of the table. How do you figure out which entry of the dictionary corresponds to that cell? On the other hand, if you use an array, the mapping between table rows and data items is simple.
精彩评论