Reputation: 5077
For offline use of mapbox I created a mymap.mbtiles file which my app will use for displaying a map. A user can press a button and the corresponding .mbtiles file will be downloaded and saved in the documents directory.
But my app crashes on this line:
RMMBTilesSource *offlineSource = [[RMMBTilesSource alloc] initWithTileSetResource:@"MYMAP" ofType:@"mbtiles"];
_mapView = [[RMMapView alloc] initWithFrame:self.view.bounds andTilesource:offlineSource];
The error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
like in this question.
This used to work fine but somewhere during my update to a newer version of MapBox this error occured.
The answer to the question in that link says that your .mbtiles file needs to be part of your projects target and added to the bundle. Is downloading the file and saving it to the documents directory not enough? If not how can I fix it so the .mbtiles file is downloadable instead of preimported by the developer.
Upvotes: 1
Views: 429
Reputation: 5128
Instead of using -initWithTileSetResource:ofType:
, which is meant for bundle resources, try -initWithTileSetURL:
and point at the file in the documents directory.
Upvotes: 2