J'essaie de créer ma première application iOS qui analyse json à partir d'un service Web.Analyse de json string dans iOS Objectif C
Dans mon .h je crée un tableau
NSArray *items;
Dans mon fichier .m j'appelle le site Web et stocker les données dans le tableau. Tout va bien, sauf finalement j'essaie d'afficher les données dans un uitableview.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"ItemsCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
NSLog(@"%@",items);
NSDictionary *item = [items objectAtIndex:indexPath.row];
NSString *title = [item objectForKey:@"title"];
cell.title.text = title;
return cell;
}
Le NSLog des articles produit:
{
category = code;
keyword = "";
limit = 20;
lowPrice = "";
page = 0;
products = (
{
description = "...";
mobileFriendly = 1;
popularity = 2021;
productId = code;
title = "title";
}, and so on...
)
Je reçois une erreur en essayant de faire NSDictionary * item = [Eléments objectAtIndex: indexPath.row]; Il dit faire objectAtIndex: indexPath.row est invalide.
Qu'est-ce que je fais mal?
Merci pour votre aide!
super merci! – Stephen