开发者

Alphabetically sectioned UITableView, NSSortPredicate Vs Array of arrays?

开发者 https://www.devze.com 2023-04-10 16:02 出处:网络
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-sou

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.

0

精彩评论

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

关注公众号