读/写 plist 的正确方法是什么?
在我的应用程序中,我将一些用户数据存储在两个 .plist 文件中,这些文件已经包含一些数据,但用户可以更改它。
NSString *Path = [[NSBundle mainBundle] bundlePath];
NSString *DataPath = [Path stringByAppendingPathComponent:@"Settings.plist"];
NSMutableDictionary *tempDict = [[NSMutableDictionary alloc] initWithContentsOfFile:DataPath];
它适用于模拟器,但不适用于设备。
你能帮我吗?
谢谢你!
In my app I store some user data in two .plist files which already contain some data, but the user can change it.
NSString *Path = [[NSBundle mainBundle] bundlePath];
NSString *DataPath = [Path stringByAppendingPathComponent:@"Settings.plist"];
NSMutableDictionary *tempDict = [[NSMutableDictionary alloc] initWithContentsOfFile:DataPath];
It works on the Simulator, but not on the device.
Can you help me, please?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法写入设备上的捆绑包,因此您需要获取文档或库目录的路径。
You can't write to the bundle on the device, so you need to get the path to your Documents or Library directory.