我有3個名爲level0,level1,level2的plist文件,所有這個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問題? –