writeToFile可在模拟器上运行,但不能在设备上运行 [英] writeToFile working on simulator, but not on device

查看:85
本文介绍了writeToFile可在模拟器上运行,但不能在设备上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要更改的列表:

I have a plist which I am changing:

NSString *finalPath = [path stringByAppendingPathComponent:@"KeyFrameFileByMovie.plist"];
NSMutableDictionary *keyFrameFileByMovie = [[NSMutableDictionary alloc] initWithContentsOfFile:finalPath];
[keyFrameFileByMovie setValue:keyFrameName forKey:movieName];
BOOL isOk = [keyFrameFileByMovie writeToFile:finalPath atomically:YES];

在模拟器上isOk为1 在设备上,确定为0

On the simulator isOk is 1 on the device isOK is 0

我认为这不是大小写敏感的问题,因为我有一个有效的代码:

I don't think it is a case sensative issue, because I have a getting code that works:

NSString *finalPath = [path stringByAppendingPathComponent:@"KeyFrameFileByMovie.plist"];<br>
NSDictionary *plistData =[[NSDictionary dictionaryWithContentsOfFile:finalPath] retain];

为什么writeToFile在设备上失败?

Why is does writeToFile fail on the device?

推荐答案

iPhone应用程序具有非常严格的目录结构.不幸的是,设备和模拟器上的权限是不同的.因此,这里唯一的问题可能是您没有保存在Documents目录中,而是保存在MainBundle目录中.

iPhone application has very strict directory structure. Unfortunately the permissions on the device vs simulator are diferent. So the only problem here can be that you are not saving in the Documents directory but in the MainBundle dir.

在上面的示例中,路径值是什么?

In the example above, what is the path value?

这篇关于writeToFile可在模拟器上运行,但不能在设备上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆