1

I'm working in a UITableView that is filled by data from a JSON format (link: http://data.okfn.org/data/core/country-codes/r/country-codes.json).

So, I want to divide the data from the UITableView in -alphabetical- sections, but idk how to do that.

These are the arrays I'm using for the app:

let sections:[String] = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
var mainList:[[String:String]] = []

I know that if your data were created by the developer from the app, you can use: sectionIndexTitlesForTableView, sectionForSectionIndexTitle & titleForHeaderInSection... but in this case that you can't control/create the data, how it works?

Thanks.

Joe
  • 87
  • 1
  • 13
  • 1
    Your last paragraph still applies. You just need to build your data source data into section to match the table view sections. – rmaddy Dec 07 '15 at 00:28
  • @rmaddy really??? how can I do that... because the data I'm using from JSON are inmense! And I think doing one by one is not the best way. – Joe Dec 07 '15 at 00:43
  • You have to iterate the raw data and split it up. There's really no other way. – rmaddy Dec 07 '15 at 00:44
  • @rmaddy sth like this? http://stackoverflow.com/a/28087913/5347548 – Joe Dec 07 '15 at 00:53
  • Yes, that's the basic idea. – rmaddy Dec 07 '15 at 00:54
  • @Joe Are you going to delete this question the same as the last two after you get an answer? Why are you doing that? – zaph Dec 07 '15 at 02:52

0 Answers0