iphone写入文件失败 [英] iphone write to file fails
本文介绍了iphone写入文件失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将一些数据写入plist文件,但它在设备上失败但在模拟器中没有。我迷路了,不知道在哪里寻找解决方案。
I'm writing some data to a plist file but it fails on the device but not in the simulator. I'm lost, don't know where to look for a solution.
这是我的代码:
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
[dict setObject:nameField.text forKey:@"name"];
[dict setObject:emailField.text forKey:@"email"];
BOOL ret = [dict writeToFile:[[NSString alloc] initWithString:[[NSBundle mainBundle] pathForResource:@"settings" ofType:@"plist"]] atomically:YES];
NSLog(@"%d",ret);
[dict release];
日志在设备上返回0,但在模拟器中返回1。
The log returns 0 on the device, but 1 in the simulator.
有人可以帮帮我吗?
推荐答案
你为什么要写资源目录?你检查这?
Why are you trying to write in resource directory? Have you checked this?
这篇关于iphone写入文件失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文