plist ファイルから整数を取得し、それをインクリメントして、plist ファイルに書き戻したいと考えています。「Levels.plist」ファイル内には、キーLevelNumber
が で値がの行があります1
。このコードを使用して値を取得します。
NSString *filePath = [[NSBundle mainBundle]pathForResource:@"Levels.plist" ofType:@"plist"];;
NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
lvl = [[plistDict objectForKey:@"LevelNumber"]intValue];
NSLog(@"%i", [[plistDict objectForKey:@"LevelNumber"]intValue]);
これを実行すると、コンソール出力が 0 になります。何が間違っているのか教えてもらえますか?