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

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -