我正在尝试将以下plist文件加载到NSMutableArray中。
我使用如下的Objective C代码:
<?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>Item 0</key>
<dict>
<key>title</key>
<string>East Coast</string>
</dict>
<key>Item 1</key>
<dict>
<key>title</key>
<string>West Coast</string>
</dict>
<key>Item 2</key>
<dict>
<key>title</key>
<string>South Rhodes</string>
</dict>
</dict>
</plist>
我使用如下的Objective C代码:
- (void)viewDidLoad
{
[super viewDidLoad];
// Load data from the plist file
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Menu" ofType:@"plist"];
self.menuArray = [NSMutableArray arrayWithContentsOfFile:plistPath];
}
plist的名称是Menu.plist。
代码执行后,menuArray为空。
奇怪的是,在苹果公司的“QuickContacts”示例代码中使用相同的代码一切都正常工作。
感谢您的时间。