objective c - Read data from geoJson file in ios -
i'm trying read data geojson file using code:
nsstring *jsonpath = [[nsbundle mainbundle] pathforresource:@"roads_json" oftype:@"geojson"]; nsdictionary *json = [nsjsonserialization jsonobjectwithdata:[[nsdata alloc] initwithcontentsoffile:jsonpath] options:0 error:nil]; nslog(@"points:%@",json);
and output:
points:(null)
any idea plz...
it best pass nserror
object when using nsjsonserialization
. way can know wrong.
nserror *error; nsdictionary *json = [nsjsonserialization jsonobjectwithdata:[[nsdata alloc] initwithcontentsoffile:jsonpath] options:0 error:&error]; if (error) { nslog(@"could not serialize geojson file: %@", [error localizeddescription]); } else { //geojson has been decoded }
Comments
Post a Comment