0

I'm currently working with the Mapbox SDK for iOS and got a question about general data management.

I got a table with coordinates and some other attributes and the table has about 600 to 700 rows. Now I was wondering what would be the best way to store and init this data within my app? And the second question, where should I initialize this data?

Question #1: Should I put all my data in the code and init an array with it? Or would it be better to create a local database and query the data from there? Or any other file format? Question #2: Should I init the data/connect to the database within the appDelegate? Or where is the best place to do this?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
zeekrey
  • 391
  • 6
  • 16
  • If you're using mapbox, why don't you just store your data in the tiles. If your data is persistent and unchanging, then mapbox allows you to serve it baked into the tiles. – Logan Mar 02 '14 at 18:02
  • If I understood you correctly you mean the RMInteractiveSource protocol, right? If I would use this, it would be necessary to add a point layer to tilemill. This means, if I need to add a point its necessary to change the underlying shape file, correct? In this case, even if the data only changes once a year, a json file would be the more convenient solution. Or what do you think? – zeekrey Mar 03 '14 at 11:15
  • 1
    It's been a while since I've used MapBox, but I remember going to a live editor in my browser where I had the option to upload data. This data would then be delivered right on the tiles themselves. If your data is very dynamic and constantly changing, it won't work. But, if your data is something that's relatively consistent like 2000-2001 arrest records, it would definitely be the way to go. – Logan Mar 03 '14 at 18:41

2 Answers2

1

Core Data is super fast and super efficient, so if the data you have is static, I would just add it to your target in the format you have (JSON, XML) and then on the app first run process it and store it into Core Data, which is basically an sql database. From then you can access it everywhere in your project. And you will not have to hold 700 items array in memory.

Apple provides template for Core Data stack which is loaded in the AppDelegare, so if you create new empty project and tick use core data, you will get all the methods in AppDelegate. You can then copy them into your project, define your model, create NSManagedObject subclasses and update your core data methods to reflect correct model and file name.

Alternativelly, you can also include preloaded sqlite into your project, but I would keep it easy and use the first option.

Martin Koles
  • 5,177
  • 8
  • 39
  • 59
0

logan's suggestion is close -- you want TileMill to bake the data into the tiles themselves, then they can be brought down as an RMMapboxSource or RMMBTilesSource overlay in the SDK.

If your data needs more freshness than that, 600-700 records should work ok right in mapView.annotations since they are only drawn when on screen (layer requested from delegate upon need to draw each).

incanus
  • 5,100
  • 1
  • 13
  • 20