Alphabetically sectioned UITableView, NSSortPredicate Vs Array of arrays?
I have an array of simple objects. 开发者_StackOverflowI wish to display these in a sectioned table view sorted alphabetically, the first section being "A", the second being "B", etc. The data-source of this table, i.e. the simple array, may be updated frequently (same every ten minutes).
I'm trying to figure out if its better to have an two dimensional array with each sub-array corresponding to a character in the alphabet / populating a section. Or use predicates to get the objects for each section & sort them alphabetically?
I'm leaning towards the multi-dimensional array approach as it might be less resource intensive than doing a search & sort predicate computation for each section?
Look at the UILocalizedIndexedCollation
class and its associated sample codes. It is designed especially for this purpose.
You may be interested in this doc too.
精彩评论