Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>change </p> <pre><code>news = [responseDict objectAtIndex:0]; </code></pre> <p>to </p> <pre><code>news = responseDict; </code></pre> <p>in <code>- (void)connectionDidFinishLoading:(NSURLConnection *)connection</code> method.</p> <p><strong>Update:</strong></p> <pre><code>/* -viewDidLoad, just fix warning "unused var" */ // [[NSURLConnection alloc] initWithRequest:request delegate:self]; [NSURLConnection connectionWithRequest:request delegate:self]; </code></pre> <p>-</p> <pre><code>/* connectionDidFinishLoading */ // NSArray *responseDict = [NSJSONSerialization JSONObjectWithData:data options:nil error:nil]; NSArray *responseDict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:NULL]; //news = [responseDict objectAtIndex:0]; // [mainTableView reloadData]; if ([responseDict isKindOfClass:[NSArray class]]) { news = responseDict; [mainTableView reloadData]; } else { NSLog(@"JSON Error."); } </code></pre> <p>-</p> <pre><code>NSString *_getString(id obj) { return [obj isKindOfClass:[NSString class]] ? obj : nil; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { // ... // cell.textLabel.text = [[news objectAtIndex:indexPath.row] objectForKey:@"metaScore"]; // cell.detailTextLabel.text = [[news objectAtIndex:indexPath.row] objectForKey:@"title"]; /** Your JSON value maybe NSNull */ cell.textLabel.text = _getString([[news objectAtIndex:indexPath.row] objectForKey:@"metaScore"]); cell.detailTextLabel.text = _getString([[news objectAtIndex:indexPath.row] objectForKey:@"title"]); return cell; } </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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