data structure best practices for UITableView datasource
I am trying to figure out whats the best data structure to hold the data source for a UITableView. I am looking for something as robust as possible - a structure that will hold data for the different sections, and which will enable convenient add and remove of objects. I saw a few implemen开发者_如何转开发tations using NSMutableArrays and dictionaries, but I am still not convinced as to which approach is the most robust.
Appreciate your help and thoughts.
NSMutableArray is the most efficient since the index path for row and section readily convert to integers which can be used to access the array elements.
Depends on really how complex your data is. If its just couple of strings then an Array of NSStrings will suffice. If its like an image path, a text label and its description then maybe an array of custom class holding that data. I almost always go for the Arrays since you can get your desired object from it with the objectAtIndex:indexPath.row bit.
精彩评论