【发布时间】:2011-04-23 04:38:08
【问题描述】:
我正在学习如何使用 plist 文件在我的 iPhone 应用程序中存储数据。我一直在这个网站上阅读一堆关于 plist 和 dictionaryWithContentsOfFile 的问题,但看不出我做错了什么。
以下行返回 nil(“字典为空”到控制台)。
NSLog(@"The dictionary is %@",[NSDictionary dictionaryWithContentsOfFile:@"myFile"]);
myFile.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>name</key>
<string>john</string>
<key>aname</key>
<string>jen</string>
</dict>
</plist>
我错过了什么吗?
【问题讨论】:
标签: iphone objective-c properties plist nsdictionary