Domanda

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?

È stato utile?

Soluzione

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.

Altri suggerimenti

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).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top