Note that there are some explanatory texts on larger screens.

plurals
  1. POJSON data not kept in order
    primarykey
    data
    text
    <p>I have returned json data that is arranged from most views to least views, but it is arranged completely wrong in the table view... here is what it looks like</p> <p>screenshot of table </p> <p><img src="https://i.stack.imgur.com/RQSCN.png" alt="enter image description here"></p> <p>here is the array returned</p> <pre><code> { author = edmiester777; description = "test post #3"; id = 3; imageURL = "https://lh5.googleusercontent.com/-nmbZ4yKmKyQ/Tz6t5kpwAuI/AAAAAAAAADA/CO0s0VhvPDM/w800-h800/potion.jpg"; pubDate = "2013-07-01 12:49:01"; title = "Post #3"; views = 64774; }, { author = edmiester777; description = "@*$(DS(XC#*$&amp;@(())));"; id = 1; imageURL = "http://0.tqn.com/d/sbinformation/1/0/D/A/twitter_newbird_boxed_whiteonblue.png"; pubDate = "2013-07-01 12:21:01"; title = "First Post Ever!"; views = 1035; }, { author = edmiester777; description = "this post is testing the UIImage loading capability of the custom table view"; id = 2; imageURL = "http://greatergood.berkeley.edu/images/uploads/Thnx4-logo-small.png"; pubDate = "2013-07-01 12:46:28"; title = "Second Post Ever!"; views = 645; } </code></pre> <p>what could be going wrong when displaying the data?</p> <p>code:</p> <pre><code> - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { Regular_Cell *cell; // Configure the cell... if(indexPath.section == 0) { if(indexPath.row &lt; NUMBER_OF_DYNAMIC_ROWS_RECENT) { cell = [tableView dequeueReusableCellWithIdentifier:@"default"]; if(cell == nil) { cell = [[Regular_Cell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"default"]; } [cell.title_label setText:[self.recent_array_titles objectAtIndex:[indexPath row]]]; [cell.views_label setText:[self.recent_array_views objectAtIndex:[indexPath row]]]; [cell.author_label setText:[self.recent_array_authors objectAtIndex:[indexPath row]]]; [cell setPoll_idFromString:[self.recent_array_poll_id objectAtIndex:[indexPath row]]]; //options for image view cell.desc_image.contentMode = UIViewContentModeScaleAspectFill; NSString *imageURL = [self.recent_array_poll_images objectAtIndex:[indexPath row]]; NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:imageURL]]; [cell.desc_image setImage:[UIImage imageWithData:imageData]]; } else if(indexPath.row == NUMBER_OF_DYNAMIC_ROWS_RECENT) { cell = [tableView dequeueReusableCellWithIdentifier:@"See More"]; if(cell == nil) { cell = [[Regular_Cell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"See More"]; } } else { cell = nil; } } if(indexPath.section == 1) { if(indexPath.row &lt; NUMBER_OF_DYNAMIC_ROWS_TOP) { cell = [tableView dequeueReusableCellWithIdentifier:@"default"]; if(cell == nil) { cell = [[Regular_Cell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"default"]; } [cell.title_label setText:[self.recent_array_titles objectAtIndex:[indexPath row]]]; [cell.views_label setText:[self.recent_array_views objectAtIndex:[indexPath row]]]; [cell.author_label setText:[self.recent_array_authors objectAtIndex:[indexPath row]]]; [cell setPoll_idFromString:[self.recent_array_poll_id objectAtIndex:[indexPath row]]]; //options for image view cell.desc_image.contentMode = UIViewContentModeScaleAspectFill; NSString *imageURL = [self.recent_array_poll_images objectAtIndex:[indexPath row]]; NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:imageURL]]; [cell.desc_image setImage:[UIImage imageWithData:imageData]]; } else if(indexPath.row == NUMBER_OF_DYNAMIC_ROWS_TOP) { cell = [tableView dequeueReusableCellWithIdentifier:@"See More"]; if(cell == nil) { cell = [[Regular_Cell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"See More"]; } } else { cell = nil; } } return cell; } </code></pre> <p>this is how i get each individual array</p> <pre><code> -(void)addRecentCells { NSArray *recArray = [Global_Vars get_json_results_for_recent]; self.recent_array_titles = [[NSMutableArray alloc]init]; self.recent_array_authors = [[NSMutableArray alloc]init]; self.recent_array_views = [[NSMutableArray alloc]init]; self.recent_array_poll_id = [[NSMutableArray alloc]init]; self.recent_array_poll_images = [[NSMutableArray alloc]init]; for(NSDictionary *poll in recArray) { [self.recent_array_titles addObject:poll[@"title"]]; [self.recent_array_authors addObject:[NSString stringWithFormat:@"Author: %@",poll[@"author"]]]; [self.recent_array_views addObject:[NSString stringWithFormat:@"Views : %@",poll[@"views"]]]; [self.recent_array_poll_id addObject:[NSString stringWithFormat:@"%@",poll[@"id"]]]; [self.recent_array_poll_images addObject:[NSString stringWithFormat:@"%@",poll[@"imageURL"]]]; NUMBER_OF_DYNAMIC_ROWS_RECENT = self.recent_array_titles.count; } [self.tableView reloadData]; } -(void)addTopViewedCells { NSArray *topArray = [Global_Vars get_json_results_for_top_viewed]; self.top_views_array_titles = [[NSMutableArray alloc]init]; self.top_views_array_authors = [[NSMutableArray alloc]init]; self.top_views_array_views = [[NSMutableArray alloc]init]; self.top_views_array_poll_id = [[NSMutableArray alloc]init]; self.top_views_array_poll_images = [[NSMutableArray alloc]init]; for(int i = 0; i &lt; topArray.count; i++) { NSDictionary *poll = [topArray objectAtIndex:i]; [self.top_views_array_titles addObject:poll[@"title"]]; [self.top_views_array_authors addObject:[NSString stringWithFormat:@"Author: %@",poll[@"author"]]]; [self.top_views_array_views addObject:[NSString stringWithFormat:@"Views : %@",poll[@"views"]]]; [self.top_views_array_poll_id addObject:[NSString stringWithFormat:@"%@",poll[@"id"]]]; [self.top_views_array_poll_images addObject:[NSString stringWithFormat:@"%@",poll[@"imageURL"]]]; NUMBER_OF_DYNAMIC_ROWS_TOP = self.top_views_array_titles.count; } [self.tableView reloadData]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload