ios - i can't get all the URL from my json. this code show only first URL of json -


- (void)viewdidload {     [super viewdidload];      nsurl *url = [nsurl urlwithstring:@"http://www.xovak.com/json_logo.php"];     nsdata *data = [nsdata datawithcontentsofurl:url];     nserror *error;      nsmutabledictionary *json = [nsjsonserialization jsonobjectwithdata:data options:kniloptions error:&error];     nsdictionary *logos = [[[json valueforkey:@"logos"]objectatindex:0]mutablecopy];     nsmutablearray *img = [[nsmutablearray alloc]init];      (id item in logos) {         [img addobject:[logos objectforkey:@"image_file"]];         nslog(@"%@",img);     } } 

another way of getting imagfile json response. please check it.

nsurl *url = [nsurl urlwithstring:@"http://www.xovak.com/json_logo.php"]; nsdata *data = [nsdata datawithcontentsofurl:url]; nserror *error;  nsmutabledictionary *json = [nsjsonserialization jsonobjectwithdata:data options:kniloptions error:&error]; nsmutablearray *img = [[nsmutablearray alloc]init]; nsarray *listofurl = [[nsarray alloc] init]; nsarray *websitedetails = (nsarray *) [json objectforkey:@"logos"];  for(int count=0; count<[websitedetails count]; count++) {     nsdictionary *websiteinfo = (nsdictionary *) [websitedetails objectatindex:count];     nsstring *imagefile = (nsstring *) [websiteinfo objectforkey:@"image_file"];     if([imagefile length]>0)     {         nslog(@"imagefile url is: %@",imagefile);         [img addobject:imagefile];     } }  listofurl = img;   ---------// add method in tableview cell row @ indexpath method//-----------------  // logic downloading image url , show in tableviewcell //get dispatch queue  dispatch_queue_t concurrentqueue = dispatch_get_global_queue(dispatch_queue_priority_default, 0);  //this start image loading in bg dispatch_async(concurrentqueue, ^{      nsurl *url = [nsurl urlwithstring:[listofurl objectatindex:indexpath.row]];     nsdata *image = [[nsdata alloc] initwithcontentsofurl:url];      //this set image when loading finished     dispatch_async(dispatch_get_main_queue(), ^{          cell.imageview.image = [uiimage imagewithdata:image];     }); }); 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -