2013-11-21 41 views
0

我正在使用FTPHelper执行基本的下载/上传FTP功能。使用它上传到我的目的地时,我一直频繁发生崩溃。在第一次上传时似乎并没有发生崩溃,但随着我进行后续的调用,崩溃的可能性越来越大。 Xcode中吐出EXC_BAD_ACCESS(代码= 1,地址=的0x30)在辅助类::使用iOS上的FTP库进行上传时,EXC_BAD_ACCESS/SIGSEGV(CFWriteStreamOpen)

success = CFWriteStreamOpen(writeStream); 

我已经启用异常断点和僵尸,但我没有看到任何东西我可以感517线的。下面是什么我的堆栈跟踪看起来像在每个失事扣:

enter image description here

我已经能够重新与其他几个FTP库(BlackRacconFTPManager)此相同的堆栈跟踪。

上传的文件是用户与用户界面交互产生的简单文件,也就是说它是基于用户在屏幕上选择的内容而动态生成的。这里是生成,保存在本地代码,并上传文件:

//Prepare to write a new file to the device and then upload it 
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *documentsDirectory = [paths objectAtIndex:0]; 
NSString *putContent = [NSString stringWithFormat:@"V%d\n", (int)(funnySlider.value * -1)]; 
NSString *writepath = [documentsDirectory stringByAppendingPathComponent:@"foo.dat"]; 

//if the path exists 
if([[NSFileManager defaultManager] fileExistsAtPath:writepath]){ 

    //Upload the newly created file 
    [putContent writeToFile:writepath atomically:NO encoding:NSASCIIStringEncoding error:nil]; 
    [FTPHelper upload:@"foo.dat"]; 
} 

一些奇怪的事情,我想强调,以及...灌装foo.dat有很多的繁文缛节内容,以增加其文件大小品牌该应用程序更稳定。在100KB +以上几乎可靠。使用iPod Touch第四代时我也没有崩溃(好吧,我有一个,但它是在几十次和几十次测试之后)。然而,iPhone和iPad却做到了。任何想法如何解决这个问题或为什么它可能会发生?我应该放弃这种上传方式吗?

回答

0

发布的问题中遇到的问题实际上是CFFTPStream中报告的错误。当这篇文章没有引起任何关注时,我从另一篇发表在Apple开发论坛上的帖子中收到了这些信息。

调用CFWriteStreamCreateWithFTPURL后,立即禁用流的持续连接,像这样:

CFWriteStreamSetProperty(writeStream, 
         kCFStreamPropertyFTPAttemptPersistentConnection, 
         kCFBooleanFalse); 

的更多信息,可以发现here in another StackOverflow question我做一些更多的研究,当在和the post I made to the dev forums.跌跌撞撞希望这可以帮助别人!