5

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 =     (
);
}

そして私はこのコードを使用しています:

             //Get data from dictionary
             NSMutableArray *foto = [[NSMutableArray alloc]init];
             foto = [OnlineObjects objectAtIndex:1];

ただし、「fotoarray」配列は、NSMutableArrayから情報を取得しようとして空のままになります。

             //Get only the nombre Key of the NSMutableArray
             NSArray *fotoarray = [foto valueForKey:@"nombre"];

キー名が「nombre」のすべてのオブジェクトで配列を作成する方法は何ですか?

4

1 に答える 1

13

あなたが投稿したのはの説明です(これからNSDictionaryそれを呼びましょう)。配列からすべての値myDictを取得する最も簡単な方法は次のとおりです。nombrefotos

NSArray *nombres = [myDict valueForKeyPath:@"fotos.nombre"];
于 2012-08-31T18:55:34.897 に答える