0

I'm writing a simple iOS App to map about 130,000 items.

I took the raw data file and massaged each line to look like:

array.append(class(latitude:46.222813, longitude:6.138866))

But when I try to copy 130,000 lines or even 25,000 at a time, Xcode just hangs.

Now, I'm happy to copy/paste 1000 at a time, but was wondering if I should be dealing with a sqlite database? Or just a .CSV text file in my project...

Thoughts? Suggestions? Admonitions? ;)

Zonker.in.Geneva
  • 1,389
  • 11
  • 19

1 Answers1

4

Put the data in a file or database. Then you have code that loads the file/data and iterates over each entry.

Now your code is now about a dozen lines of code instead of 130,000 and the coordinates are not hardcoded in your app.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • Thanks!! Are you thinking a CSV file, a sql database, or something else? I haven't learned how to deal with files in my app, but that was going to be my first Google search this morning. – Zonker.in.Geneva Oct 06 '15 at 06:24
  • 1
    I'd use a database file. This way the data is stored in a much more usable format (especially for so much data) and your app will have a lot more flexibility if you just want to query some of the data and you don't need the whole file in memory at once. – rmaddy Oct 06 '15 at 14:37
  • quick follow-up question, as it's late and i can't seem to find the answer quickly..... when you say "database file" do you mean Core Data? Or can I create a sqlite file on my Mac and then drag-drop it into my Xcode project and interact with it there with code? – Zonker.in.Geneva Oct 06 '15 at 22:28
  • Personally I'd use SQLite because I don't mind working at that level. Core Data is probably huge overkill to simply read data from a static database table. – rmaddy Oct 06 '15 at 22:32
  • So, I ended up using a tab-delimited file. It takes a while to load, so I might try to find a way to speed it up using another data storage option. – Zonker.in.Geneva Oct 14 '15 at 21:44