Friday 15 April 2011

ios - Convert JSON to NSArray -



ios - Convert JSON to NSArray -

i have json array beingness output on page. convert json array nsarray.

this json output on web page:

[{"city":"current location"},{"city":"anaheim, ca"},{"city":"los angeles, ca"},{"city":"san diego, ca"},{"city":"san francisco, ca"},{"city":"indianapolis, in"}]

this nsurl phone call , nsjsonserialization:

nsstring *cityarrayurl = [nsstring stringwithformat:@"http://site/page.php"; nsdata *citydata = [nsdata datawithcontentsofurl:[nsurl urlwithstring:cityarrayurl]]; nserror *error; nsdictionary *cityjson = [nsjsonserialization jsonobjectwithdata:citydata options:kniloptions error:&error];

i turn nsdictionary called cityjson nsarray. can allow me know next step might be? give thanks you!

how this?

cityarray = [[nsmutablearray alloc] init]; nsmutablearray *testfeeds = [nsjsonserialization jsonobjectwithdata: citydata options:nsjsonreadingmutablecontainers error:nil]; [cityarray addobjectsfromarray:testfeeds];

ios objective-c nsarray nsjsonserialization

No comments:

Post a Comment