IOS在NS(Mutable)Dictionary中获取一个数组

Ben*_*Ben 5 ios

我试图在NSMutableDictionary中获取一个如下所示的数组:

{
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 =     (
);
}
Run Code Online (Sandbox Code Playgroud)

我正在使用此代码:

             //Get data from dictionary
             NSMutableArray *foto = [[NSMutableArray alloc]init];
             foto = [OnlineObjects objectAtIndex:1];
Run Code Online (Sandbox Code Playgroud)

但是"fotoarray"数组保持空,试图从NSMutableArray获取信息.

             //Get only the nombre Key of the NSMutableArray
             NSArray *fotoarray = [foto valueForKey:@"nombre"];
Run Code Online (Sandbox Code Playgroud)

使用键名为"nombre"的所有对象创建数组的方法是什么?

All*_*ian 13

你发布的是a的描述NSDictionary(myDict从现在开始调用它).nombre从fotos数组中获取所有值的最快方法是:

NSArray *nombres = [myDict valueForKeyPath:@"fotos.nombre"];
Run Code Online (Sandbox Code Playgroud)