[英]Device doesn't work, simulator does
What would cause code to execute on the simulator, but not execute properly on the device? 是什么会导致代码在模拟器上执行但不能在设备上正确执行?
I'm uploading a file to a server via ftp. 我正在通过ftp将文件上传到服务器。 I'm using http://code.google.com/p/s7ftprequest/
to do the uploading. 我正在使用http://code.google.com/p/s7ftprequest/
进行上传。 Is there a simpler way to upload via ftp? 是否有通过ftp上传的更简单方法?
I've tried cleaning targets and resetting everything, but that doesn't help. 我已经尝试清理目标并重置所有内容,但这无济于事。
//create file for new submission
[submission.text writeToURL:[NSString stringWithFormat:@"%d.txt", submissionNum] atomically:YES encoding:NSUTF8StringEncoding error:nil];
//create new number.txt file
NSString *numberFileString = [NSString stringWithFormat:@"%d",submissionNum];
[numberFileString writeToURL:[NSString stringWithFormat:@"number.txt"] atomically:YES encoding:NSUTF8StringEncoding error:nil];
//connect and upload submission
S7FTPRequest *ftpRequest = [[S7FTPRequest alloc] initWithURL:[NSURL URLWithString:@"ftp://cheekyapps.com/ezhighasiam"]
toUploadFile:[NSString stringWithFormat:@"%d.txt", submissionNum]];
基础常数参考指示260为NSFileReadNoSuchFileError。
Googeling "Cocoa Error 260" let me think, that you are using a path, the device doesn't understand. Googeling “可可错误260”让我想,您正在使用设备无法理解的路径。 Maybe with ~ or a path that doesnt work with the sandboxing. 可能带有〜或与沙盒不兼容的路径。
Show some code and we can tell more. 显示一些代码,我们可以讲更多。
edit 编辑
You need to construct a Path to the applications doucument folder in it sandbox. 您需要在沙箱中构造一个指向应用程序重复文件夹的路径。 This post might be a start . 这篇文章可能是一个开始 。
in short: To access the Documents folder you should do 简而言之:要访问“文档”文件夹,您应该执行
edit 编辑
This writes your file to the documents folder 这会将您的文件写入documents文件夹
NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSSting *filePath = [documentsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%d", %d.txt]];
[submission.text writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:nil];
with the same filePath you can feed your ftp-request 使用相同的文件路径,您可以提供您的ftp请求
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.