Tuesday, January 9, 2018

ios How to Arrange JSON Parsed Array Based On Page Number

ios How to Arrange JSON Parsed Array Based On Page Number




ios - How to Arrange JSON Parsed Array Based On Page Number? -

i newbie in ios development parsed json info data

{ mid: "1", name: "august 2014", front_image:"http://www.truemanindiamagazine.com/webservice/magazineimage/frontimage/1.jpg", title: "august fist edition", release_date: "2014-08-01", short_description: "here nowadays first time our mag trueman india. �trueman india� covers bollywood gossips, cinema reviews, upcoming movies, f", current_issue: 0, -demopage: [ { link:my image url page_no: "1" }, { link: image url, page_no: "16" }, { link: image url, page_no: "2" }, { link: image url, page_no: "22" }, { link: image url, page_no: "25" }, { link: image url, page_no: "26" },

and parsed info 2 array as

nserror* error; nsdictionary *jsondict = [nsjsonserialization jsonobjectwithdata:responsedata options:kniloptions error:&error]; self.imagesa= nil; if([jsondict count]>0) { nsarray *arrdata = [jsondict objectforkey:@"data"]; if([arrdata count]>0) { nsdictionary *imgdict = [arrdata objectatindex:1]; if([imgdict count]>0) { nsmutablearray *imgslinkarray = [imgdict objectforkey:@"demopage"]; self.imagesa = imgslinkarray; } } }

then parsed , got aresult want here 1 problem taht when show image page number in scrollview show image in per got json info want imageview based on pagenumber 1 upto info array size.please give me solution arrange image based on page number wise here code image , page number parsing

for(int index=0; index < [self.imagesa count]; index++) { nsdictionary *dict=[self.imagesa objectatindex:index]; nsstring *image=[dict valueforkey:@"link"]; nsstring *pagenumber=[dict valueforkey:@"page_no"]; smallimage = [[uiimageview alloc] init]; pagelabel=[[uilabel alloc]init]; [pagelabel setbackgroundcolor:[uicolor clearcolor]]; [smallimage sd_setimagewithurl:[nsurl urlwithstring:image] placeholderimage:[uiimage imagenamed:@"1.png"]]; [pagelabel settext:[nsstring stringwithformat:@"page%@",pagenumber]];

and added label , imageview scrollview working want not show image based on page nuber ! upto array size please give me solution that.

sort imageslinkarray way:

self.imagesa = [[imgslinkarray sortedarrayusingcomparator:^nscomparisonresult(id obj1, id obj2) { if ([obj1[@"page_no"] intvalue] > [obj2[@"page_no"] intvalue]) { homecoming nsordereddescending; } else if ([obj1[@"page_no"] intvalue] < [obj2[@"page_no"] intvalue]) { homecoming nsorderedascending; } homecoming nsorderedsame; }] mutablecopy];

ios arrays json uiscrollview

go to link download
download
alternative link download

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.