I’ve got this response from JSOn web service:
categoria = (
{
"id_categoria" = 61;
imagen = "http://exular.es/mcommerce/image/data/ipod_classic_4.jpg";
nombre = Gorras;
},
{
"id_categoria" = 59;
imagen = "http://exular.es/mcommerce/image/data/ipod_touch_5.jpg";
nombre = Camisetas;
},
{
"id_categoria" = 60;
imagen = "http://exular.es/mcommerce/image/data/ipod_nano_1.jpg";
nombre = Pantalones;
}
);
}
It is feed in a dictionary in this piece of code:
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
//data =nil;
NSLog(@"JSNON %@", responseString);
NSDictionary *results = [responseString JSONValue];
NSLog(@"JSNON %@", results);
I need to iterate all the categories in the dictionary and create an NSArray that contains objects Categories with properties “name” and image”.
Many thanks
This will create an array of your category objects. You can pass this array of dictionaries/objects to your custom object or just iterate through it pulling what you need.
This is just assuming your init is set to handle a dictionary. There isn’t enough code to know, but you should be able to figure it out from here.