I am trying to get an array inside a NSMutableDictionary that looks like this:
{
coments = (
);
"foto_user" = "<null>";
fotos = (
{
fecha = "2012-08-31 19:44:31";
id = 4926;
nombre = "image5773.jpg";
posicion = 0;
ruta = "img/";
tipo = 1;
},
{
fecha = "2012-08-31 19:44:31";
id = 4927;
nombre = "image1779.jpg";
posicion = 0;
ruta = "img/";
tipo = 1;
},
{
fecha = "2012-08-31 19:44:31";
id = 4928;
nombre = "image5938.jpg";
posicion = 0;
ruta = "img/";
tipo = 1;
},
{
fecha = "2012-08-31 19:44:32";
id = 4929;
nombre = "image4424.jpg";
posicion = 0;
ruta = "img/";
tipo = 1;
}
);
"have_coments" = 0;
id = 40505;
"id_lugar" = "<null>";
"id_pais" = 28;
"id_user" = "<null>";
iso = fr;
link = "<null>";
lugar = Paris;
"nombre_pais" = "France";
root = "http://www.domain.com/";
tags = (
);
titulo = "Sunset";
"url_share" = "http://www.friktrip.com/experiencia/40505";
videos = (
);
}
And I am using this code :
//Get data from dictionary
NSMutableArray *foto = [[NSMutableArray alloc]init];
foto = [OnlineObjects objectAtIndex:1];
But the "fotoarray" array stay empty trying to get the info from the NSMutableArray.
//Get only the nombre Key of the NSMutableArray
NSArray *fotoarray = [foto valueForKey:@"nombre"];
What is the way to make an Array with all objects with the key name "nombre" ?
What you have posted is the description of an NSDictionary
(lets call it myDict
from now on). The quickest way to get all nombre
values from fotos
array is this:
NSArray *nombres = [myDict valueForKeyPath:@"fotos.nombre"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With