私はlevel0、level1、level2という名前の3つの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を1つだけ使用して3つの辞書を追加することにしました。私はplistファイルを使用する上記の例のようなplistから1つの辞書だけを読むことができます。
助けを借りてタンク!
levels.plistでの問題は何ですか? –