[英]Device doesn't work, simulator does
是什么会导致代码在模拟器上执行但不能在设备上正确执行?
我正在通过ftp将文件上传到服务器。 我正在使用http://code.google.com/p/s7ftprequest/
进行上传。 是否有通过ftp上传的更简单方法?
我已经尝试清理目标并重置所有内容,但这无济于事。
//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 “可可错误260”让我想,您正在使用设备无法理解的路径。 可能带有〜或与沙盒不兼容的路径。
显示一些代码,我们可以讲更多。
编辑
您需要在沙箱中构造一个指向应用程序重复文件夹的路径。 这篇文章可能是一个开始 。
简而言之:要访问“文档”文件夹,您应该执行
编辑
这会将您的文件写入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];
使用相同的文件路径,您可以提供您的ftp请求
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.