【发布时间】:2016-08-22 19:34:08
【问题描述】:
我有 3 个名为 level0、level1、level2 的 plist 文件,所有这些 plist 具有相同的结构,它由数字变量和数组组成。我用这个 plist 中的数据初始化我的应用程序。
+(instancetype)levelWithNum:(int)levelNum; {
NSString* fileName = [NSString stringWithFormat:@"level%i.plist", levelNum];
NSString* levelPath = [[[NSBundle mainBundle]resourcePath]stringByAppendingPathComponent:fileName];
NSDictionary *levelDic = [NSDictionary dictionaryWithContentsOfFile:levelPath];
NSAssert(levelDic, @"level no loaded");
Level *l = [[Level alloc]init];
l.coinsPerLvl = [levelDic[@"coinsPerLvl"] integerValue];
l.words = levelDic[@"words"];
return l;
}
现在我决定只使用一个 plist 并在其中添加 3 个字典。我怎样才能从 plist 中只读取一本字典,就像上面我使用 plist 文件的示例一样。
坦克寻求帮助!
【问题讨论】:
-
levels.plist 有什么问题?
标签: ios objective-c plist