Sunday, 15 April 2012

ios - Create an NSArray from JSON data -



ios - Create an NSArray from JSON data -

i have info in json format looks this:

{"yrmonth":201109,"stryrmonth":"sep-2011","value":"49275.14"} {"yrmonth":201110,"stryrmonth":"oct-2011","value":"52087.22"} etc...

using nsjsonserialization stored info in array called "indicator". when want utilize info , display items key "value" in tableview, can fine with:

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"maincell"]; cell.textlabel.text = [[indicator objectatindex:indexpath.row] objectforkey:@"value"]; homecoming cell; }

my question is: how can create array can utilize outside of cellforrowatindexpath values each key? example:

an array key "stryrmonth" contains only: "sep-2011", "oct-2011", etc... array key "value" contains only: "49275.14", "52087.22", etc...

what utilize "value" array plot line in coreplot , "stryrmonth" array define de x-axis labels of graph.

thanks in advance help!

you can utilize key-value coding , [nsarray valueforkey:] method (reference)

nsarray *stryrmontharray = [indicator valueforkey:@"stryrmonth"]; nsarray *valuearray = [indicator valueforkey:@"value"];

ios objective-c json core-plot

No comments:

Post a Comment