objective c - How to filter json data using UISegmentedControl in iOS -
objective c - How to filter json data using UISegmentedControl in iOS -
i working ios apps developer. json response need consume available @ http://pastie.org/9304213 . using want filter info in uisegmentcontrol 3 buttons. i.e 1. day 2. week 3.month.
->if click date segment command displays today info in uitableview controller.
->if click week segment command displays current week info in uitableview controller.
->if click month segment command displays current month info in uitableview controller.
i new ios programming. please guide.
this might help you. fetching , parsing json data, can utilize in controller .m file. have check on whether server sending json in proper format or not. json should start '[' or '{'.
nsurl *url=[nsurl urlwithstring:@"yourserviceurl"]; nsdata *response = [nsdata datawithcontentsofurl:url]; nserror *error; nsdictionary *jsonarray = [nsjsonserialization jsonobjectwithdata:response options: nsjsonreadingmutablecontainers error: &error];
now have info in nsdictionary object , can extract particular info using objectforkey
or valueforkey
functions :
_array = [jsonarray valueforkey:@"keyfield"];
now if want toggle between 3 switch values, can seek this.
-(ibaction)segmentchanged:(id)sender { if ([_segmentcontrol selectedsegmentindex]==0) { //your code } else if ([_segmentcontrol selectedsegmentindex]==1) { //your code } else { //your code } }
you have connect event valuechanged
event of uisegmentcontrol
.this job when click on of segment values. identify index of clicked segment , run appropriate loop.
hope helps.
ios objective-c json nsdateformatter uisegmentedcontrol
Comments
Post a Comment