开发者

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. I'm using http://code.google.com/p/s7ftprequest/ to do the uploading. Is there a simpler开发者_高级运维 way to upload via 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]];


The Foundations Constants Reference indicates that 260 is NSFileReadNoSuchFileError.


Googeling "Cocoa Error 260" let me think, that you are using a path, the device doesn't understand. 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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜