我试图从Plist加载NSMutableDictionary。我的结果始终为NULL。从plist加载NSMutableDictionary
的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>LocNum</key>
<string>0</string>
<key>LocName</key>
<string>Head</string>
</dict>
<dict>
<key>LocNum</key>
<string>1</string>
<key>LocName</key>
<string>Left Hand</string>
</dict>
<dict>
<key>LocNum</key>
<string>2</string>
<key>LocName</key>
<string>Right Hand</string>
</dict>
....
</array>
</plist>
我的代码非常简单:
locDictionary = [[NSMutableDictionary alloc] init];
NSString *locListpath = [[NSBundle mainBundle] pathForResource:@"LocList" ofType:@"plist"];
locDictionary = [NSMutableDictionary dictionaryWithContentsOfFile:locListpath];
NSLog(@"locDictionary %@", locDictionary);
任何想法或帮助?由于
文件名区分大小写,检查是否输入了正确的文件名,并且根是数组而不是字典 – Vig
FYI - 行locDictionary = [[NSMutableDictionary alloc] init];'是毫无意义的。摆脱那条线。 – rmaddy