我和我的朋友正在开发一个从属性列表加载关卡数据的益智游戏。我们的问题似乎是对于某些字典键,它可以正确加载数据,但对于其他的则不能。此外,对属性列表进行更改往往会导致它也无法正确加载。
我的猜测是这与设备缓存属性列表数据有关,但我不确定。我们已经尝试了几乎所有我们和互联网能想到的东西,但都无济于事。(即在属性列表更改等之间从模拟器和物理设备上删除应用程序等)
我很高兴分享任何人认为可以帮助得出答案的相关代码,我只是不确定什么是相关的。所以让我知道你需要什么。
提前致谢。
这是房产清单
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>level99</key>
<dict>
<key>xDimension</key>
<integer>19</integer>
<key>yDimension</key>
<integer>7</integer>
<key>levelArray</key>
<array>
<string>E</string>
<string>*</string>
<string>R</string>
<string>B</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>Y</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>E</string>
<string>B</string>
<string>E</string>
<string>R</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>E</string>
<string>*</string>
<string>*</string>
<string>E</string>
<string>E</string>
<string>*</string>
<string>E</string>
<string>*</string>
<string>*</string>
<string>E</string>
<string>E</string>
<string>B</string>
<string>*</string>
<string>E</string>
<string>E</string>
<string>*</string>
<string>E</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>E</string>
<string>E</string>
<string>Y</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>E</string>
<string>E</string>
<string>B</string>
<string>*</string>
<string>E</string>
<string>E</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>E</string>
<string>E</string>
<string>*</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>E</string>
<string>*</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>*</string>
<string>R</string>
<string>E</string>
<string>E</string>
<string>*</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>*</string>
<string>E</string>
<string>B</string>
<string>E</string>
<string>*</string>
<string>E</string>
<string>R</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>*</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>*</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>*</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>*</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>E</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>E</string>
<string>E</string>
</array>
</dict>
<key>level10</key>
<dict>
<key>xDimension</key>
<integer>5</integer>
<key>yDimension</key>
<integer>8</integer>
<key>didBeat</key>
<false/>
<key>levelArray</key>
<array>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>B</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>B</string>
<string>B</string>
<string>*</string>
<string>B</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>*</string>
</array>
</dict>
<key>level0</key>
<dict>
<key>yDimension</key>
<integer>5</integer>
<key>xDimension</key>
<integer>5</integer>
<key>didBeat</key>
<false/>
<key>levelArray</key>
<array>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>B</string>
<string>*</string>
<string>B</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>B</string>
<string>*</string>
<string>B</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>R</string>
</array>
</dict>
<key>level1</key>
<dict>
<key>xDimension</key>
<integer>5</integer>
<key>yDimension</key>
<integer>8</integer>
<key>didBeat</key>
<false/>
<key>levelArray</key>
<array>
<string>*</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>B</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>B</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>B</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>B</string>
</array>
</dict>
<key>level2</key>
<dict>
<key>xDimension</key>
<integer>5</integer>
<key>yDimension</key>
<integer>8</integer>
<key>didBeat</key>
<false/>
<key>levelArray</key>
<array>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>B</string>
<string>*</string>
<string>B</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>B</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>Y</string>
</array>
</dict>
<key>level3</key>
<dict>
<key>xDimension</key>
<integer>5</integer>
<key>yDimension</key>
<integer>8</integer>
<key>didBeat</key>
<false/>
<key>levelArray</key>
<array>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>Y</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>B</string>
<string>*</string>
<string>B</string>
<string>*</string>
<string>*</string>
</array>
</dict>
<key>level4</key>
<dict>
<key>xDimension</key>
<integer>5</integer>
<key>yDimension</key>
<integer>8</integer>
<key>didBeat</key>
<false/>
<key>levelArray</key>
<array>
<string>Y</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>B</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>B</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>B</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>B</string>
<string>*</string>
<string>*</string>
<string>B</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>R</string>
</array>
</dict>
<key>level5</key>
<dict>
<key>xDimension</key>
<integer>5</integer>
<key>yDimension</key>
<integer>8</integer>
<key>didBeat</key>
<false/>
<key>levelArray</key>
<array>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>B</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>B</string>
<string>B</string>
<string>*</string>
<string>*</string>
<string>*</string>
</array>
</dict>
<key>level6</key>
<dict>
<key>xDimension</key>
<integer>5</integer>
<key>yDimension</key>
<integer>8</integer>
<key>didBeat</key>
<false/>
<key>levelArray</key>
<array>
<string>*</string>
<string>*</string>
<string>B</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>B</string>
<string>B</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
</array>
</dict>
<key>level7</key>
<dict>
<key>xDimension</key>
<integer>5</integer>
<key>yDimension</key>
<integer>8</integer>
<key>didBeat</key>
<false/>
<key>levelArray</key>
<array>
<string>*</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>*</string>
<string>B</string>
<string>B</string>
<string>*</string>
<string>B</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>B</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
</array>
</dict>
<key>level9</key>
<dict>
<key>levelArray</key>
<array>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>B</string>
<string>R</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>B</string>
<string>B</string>
<string>*</string>
<string>B</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>*</string>
<string>Y</string>
<string>*</string>
</array>
<key>xDimension</key>
<integer>5</integer>
<key>yDimension</key>
<integer>8</integer>
<key>didBeat</key>
<false/>
</dict>
<key>level8</key>
<dict>
<key>didBeat</key>
<false/>
<key>yDimension</key>
<integer>8</integer>
<key>xDimension</key>
<integer>5</integer>
</dict>
</dict>
</plist>
这是加载属性列表的代码
-(NSDictionary *)getLevelDictionaryForLevel:(int)level{
NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *finalPath = [path stringByAppendingPathComponent:@"Group1.plist"];
NSDictionary *plistData = [[NSDictionary alloc] initWithContentsOfFile:finalPath];
NSDictionary *currentLevelData = [plistData objectForKey:[NSString stringWithFormat:@"level%i", level]];
return currentLevelData;
}