我正在尝试从我的plist中读取一些词典,但不幸的是,我的代码在plist中看不到任何词典。这是我的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">
<dict>
<key>BestScore</key>
<integer>0</integer>
<key>Coins</key>
<integer>0</integer>
<key>UserName</key>
<string>Anonim</string>
<key>Store</key>
<dict>
<key>Shoes</key>
<dict/>
<key>Hats</key>
<dict>
<key>hatMagic2</key>
<dict>
<key>Price</key>
<integer>300</integer>
<key>name_EN</key>
<string> MAGIC HAT 2</string>
<key>plusHealth</key>
<integer>150</integer>
</dict>
<key>hatMagic1</key>
<dict>
<key>Price</key>
<integer>200</integer>
<key>name_EN</key>
<string>MAGIC HAT 1</string>
<key>plusHealth</key>
<integer>100</integer>
</dict>
<key>hatMagic</key>
<dict>
<key>Price</key>
<integer>100</integer>
<key>name_EN</key>
<string>MAGIC HAT</string>
<key>plusHealth</key>
<integer>50</integer>
</dict>
</dict>
</dict>
</dict>
</plist>
我的代码看起来像那样:
var paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as String
var path = paths.stringByAppendingPathComponent("UserInfo.plist")
var data = NSMutableDictionary(contentsOfFile: path)
println(data)
但是swift没有看到任何字典,输出:
{
BestScore = "789.5";
Coins = 289;
UserName = Anonim;
}
那么,我如何从plist中读取这些词典?