【问题标题】:Insert into array translated value from NSLocalizedString从 NSLocalizedString 插入数组翻译值
【发布时间】:2011-12-03 21:08:56
【问题描述】:

我有一个包含字典数组的 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"]];

但是,如何将值直接转换为数组,而不是键?

谢谢大家!

【问题讨论】:

    标签: xcode nsarray nsdictionary nslocalizedstring


    【解决方案1】:

    怎么样:

     NSMutableArray * arr = [[NSMutableArray alloc] initWithArray: [dict allValues]];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-02-14
      • 1970-01-01
      • 1970-01-01
      • 2019-11-20
      • 1970-01-01
      • 2016-09-15
      • 2020-04-03
      相关资源
      最近更新 更多