Note that there are some explanatory texts on larger screens.

plurals
  1. POxcode NSDictionary error multiarray
    primarykey
    data
    text
    <p>I'm new in xcode and I need help.</p> <p>I have this json:</p> <pre><code>{ "noticias": [ { "titulo":"teste" } { "titulo":"teste 2" } ] } </code></pre> <p>How i got the result ? I tried </p> <pre><code>NSDictionary *not = [noticias objectAtIndex:indexPath.row]; </code></pre> <p>But i got an error because I have the key "noticias"</p> <hr> <p><strong>Update:</strong> This is attempted code, on the basis of the answers received thus far. I have this:</p> <pre><code>- (void)fetchNoticias { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSData* data = [NSData dataWithContentsOfURL: [NSURL URLWithString: @"http://www.site.com/json"]]; NSError* error; noticias = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&amp;error]; dispatch_async(dispatch_get_main_queue(), ^{ [self.tableView reloadData]; }); }); } </code></pre> <p>Then</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; [self fetchNoticias]; } </code></pre> <p>and the final where I have the problem</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"NoticiasCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } NSArray *noticia = [noticias objectForKey:@"noticias"]; NSDictionary *not = [noticias objectAtIndex:indexPath.row]; NSString *firstTitle = [not objectForKey:@"titulo"]; cell.textLabel.text = firstTitle; //cell.detailTextLabel.text = subtitulo; [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; return cell; } </code></pre> <p>problem in line:</p> <pre><code>NSArray *noticia = [noticias objectForKey:@"noticias"]; </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. 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