iphone - create a json string from NSArray -


in iphone aplication have list of custom objects. need create json string them. how can implement sbjson or iphone sdk?

 nsarray* eventsforupload = [app.dataservice.coredatahelper fetchinstancesof:@"event" where:@"isforupload" is:[nsnumber numberwithbool:yes]];     sbjsonwriter *writer = [[sbjsonwriter alloc] init];       nsstring *actionlinksstr = [writer stringwithobject:eventsforupload]; 

and empty result.

this process simple now, don't have use external libraries, way, (ios 5 & above)

nsarray *myarray; nsdata *jsondata = [nsjsonserialization datawithjsonobject:myarray options:nsjsonwritingprettyprinted error:&error]; nsstring *jsonstring = [[nsstring alloc] initwithdata:jsondata encoding:nsutf8stringencoding]; 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -