1

辞書の配列を含む plist があります。

例:

items: (array)
    item0: (dictionary)
        Label: (string)
        Img: (string)
    item1: (dictionary)
        Label: (string)
        Img: (string)

NSLocalizedString を使用して、ラベルが翻訳されます。

このコードでは、すべてを辞書に入れ、その後配列に入れます。

NSString *myFile = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"plist"];

NSDictionary *dict = [[NSDictionary alloc]initWithContentsOfFile:myFile];

NSMutableArray *arr = [[NSMutableArray alloc] initWithArray:[dict objectForKey:@"Items"]];

ただし、キーではなく、直接変換された値を配列に配置するにはどうすればよいですか?

ありがとうございます!

4

1 に答える 1

0

どうですか:

 NSMutableArray * arr = [[NSMutableArray alloc] initWithArray: [dict allValues]];
于 2011-12-03T21:23:19.997 に答える