开发者

NSArray of values, want to display alphabetically in sections. How to distribute in correct sections?

Sorry, I'm not sure how to search for the answer to this, but I'm sure it's out there.

I have a large NSArray of strings in alphabetical order. I want to add them to a uitableview and have them distributed correctly in each section by the fir开发者_如何学Cst letter. I have the sections set up, but I'm not sure how to tell my tableview to add to the next section when the object starts with the next letter in the alphabet. Thanks for any help! It's much appreciated!


Hy

You must parse the array manually, and then tell the tableView - via delegate method - the number of sections, and items. If I were you, I would place it in a dictionary, and the keys are numbers, which are represents sections, and the values are an array of the titles. It is easy to use. You only have to parse the original array.


There is an example that describes what you want: http://www.devx.com/wireless/Article/43374/1763


I think using an NSDictionary is much more convenient in this case. An NSDictionary inherently allows you to store your data alphabetically.

Vocabulous is a great example project for this use case.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜