我有这个代码
@implementation LevelManager {
NSArray * levelPacks;
}
- (id)init {
if ((self = [super init])) {
NSString *file = [[NSBundle mainBundle] pathForResource:@"Levels" ofType:@"plist"];
levelPacks = [NSArray arrayWithContentsOfFile:file];
}
}
它读取以下名为的 plist 文件Levels.plist
<?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">
<array>
<dict>
<key>PackName</key>
<string>First Pack</string>
<key>Levels</key>
<array>
<dict>
<key>Name</key>
<string>1</string>
<key>Time</key>
<integer>60</integer>
<key>ScoreBronze</key>
<integer>20</integer>
<key>ScoreSilver</key>
<integer>25</integer>
<key>ScoreGold</key>
<integer>30</integer>
<key>Fish</key>
<dict>
<key>OrangeFish</key>
<dict>
<key>Rarity</key>
<integer>1</integer>
<key>MinTime</key>
<integer>0</integer>
</dict>
</dict>
</dict>
<dict>
<key>Name</key>
<string>2</string>
<key>Time</key>
<integer>60</integer>
<key>ScoreBronze</key>
<integer>25</integer>
<key>ScoreSilver</key>
<integer>30</integer>
<key>ScoreGold</key>
<integer>35</integer>
<key>Fish</key>
<dict>
<key>OrangeFish</key>
<dict>
<key>Rarity</key>
<integer>4</integer>
<key>MinTime</key>
<integer>0</integer>
</dict>
<key>PurpleFish</key>
<dict>
<key>Rarity</key>
<integer>2</integer>
<key>MinTime</key>
<integer>10</integer>
</dict>
</dict>
</dict>
</array>
</dict>
<dict>
<key>PackName</key>
<string>Second Pack</string>
<key>Levels</key>
<array>
<dict>
<key>Name</key>
<string>1</string>
<key>Time</key>
<integer>60</integer>
<key>ScoreBronze</key>
<integer>20</integer>
<key>ScoreSilver</key>
<integer>25</integer>
<key>ScoreGold</key>
<integer>30</integer>
<key>Fish</key>
<dict>
<key>OrangeFish</key>
<dict>
<key>Rarity</key>
<integer>5</integer>
<key>MinTime</key>
<integer>0</integer>
</dict>
<key>PurpleFish</key>
<dict>
<key>Rarity</key>
<integer>3</integer>
<key>MinTime</key>
<integer>0</integer>
</dict>
<key>YellowFish</key>
<dict>
<key>Rarity</key>
<integer>1</integer>
<key>MinTime</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</array>
</dict>
</array>
</plist>
这一直有效,直到将我的代码更新到 iOS 7,现在我得到一个包含两个项目的数组,它们的类型都为invalid
.
在 xcode 中检查变量时,它显示错误
(<invalid>) [0] = <error: expected ']'
error: 1 errors parsing expression
>
有人知道这是为什么吗?