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 回答