开发者

NSMutableArray vs. NSDictionary for a table view

I have a table view that is populated by objects in an array. I want to give the user the option to delete table entries. I was wondering if it would be easier if I used NSDictionary instead of NSMutableArray? How do you know when to use NSDictionary i开发者_如何转开发nstead of NSMutableArray?


If your data is based on a key-value scheme, use dictionary. Otherwise use an array. It is purely design decision based on the kind of data you are dealing with. If you are using dictionary, make sure that there are no multiple entities for same key!

Or even, using an array of dictionary objects would serve the purpose.

Usually NSArray is preferred as datasource rather than NSDictionary.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜