我需要访问Settings.bundle并获取带有本地化字符串的描述和标题。
答案 0 :(得分:1)
使用NSLocalizedStringFromTableInBundle功能。使用捆绑软件的URL创建NSBundle
的实例,并将其用作bundle
的参数。使用“根”作为tbl
参数的表名。
例如:
NSBundle *bundle = [[NSBundle alloc] initWithURL: ...];
NSString *string = NSLocalizedStringFromTableInBundle("SOME_KEY", "Root", bundle, "Comment");
答案 1 :(得分:1)
最后我是这样做的:
NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"];
NSBundle *settingsBundle = [NSBundle bundleWithPath:resourcePath];
NSURL *url = [settingsBundle URLForResource:@"Root" withExtension:@"plist"];
NSDictionary *dictionary = [[NSDictionary alloc] initWithContentsOfURL:url];
NSArray *preferences = dictionary[@"PreferenceSpecifiers"];
for (NSDictionary *dic in preferences){
NSString *localizedTitle = NSLocalizedStringWithDefaultValue(dic[@"Title"], @"Root", settingsBundle, dic[@"Title"], @"");
}