How to parse mapquest geocode JSON in iOS -


i trying parse json result mapquest geocode api.

nsdictionary *jsonreponsedic = [nsjsonserialization jsonobjectwithdata:mapquestdata options:0 error:&error]; nsmutablearray *resultsarray = [jsonreponsedic objectforkey:@"results"];  nsdictionary *locationdic = [resultsarray objectatindex:0]; nslog(@"loc dic %@", locationdic);  nsstring *city = [locationdic objectforkey:@"adminarea5"]; nslog(@"city : %@", city); 

i can parse until locationdic, returns

loc dic { locations =     (             {         adminarea1 = us;         adminarea1type = country;         adminarea3 = ca;         adminarea3type = state;         adminarea4 = "santa clara county";         adminarea4type = county;         adminarea5 = "los altos";         adminarea5type = city;         displaylatlng =             {             lat = "37.37964";             lng = "-122.11877";         };         dragpoint = 0;         geocodequality = point;         geocodequalitycode = p1aaa;         latlng =             {             lat = "37.37949";             lng = "-122.11903";         };         linkid = 0;         mapurl = "http://www.mapquestapi.com/staticmap/v4/getmap?key=fmjtd|luub206tl1,rg=o5-9ubah0&type=map&size=225,160&pois=purple-1,37.37949,-122.11903,0,0|&center=37.37949,-122.11903&zoom=15&rand=-159915059";         postalcode = "94022-2707";         sideofstreet = r;         street = "145 1st st";         type = s;     } ); providedlocation =     {     location = "145 1st st,los altos, ca 94022"; }; } 

then, when trying city name, log returns null. parsing right way?

it should [locationdic valueforkeypath:@"locations.adminarea5"];.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -