使用 NSOperation 下载和 FTP 文件
我正在尝试使用 NSOperation 从 FTP 服务器下载文件。我的下载基本示例是 Apple 的简单 FTP 项目。特别是,我使用的是 GetController
类中的代码。我尝试从那里下载的 URL 工作正常。
在我的 NSOperation 子类中,我重写了 start 方法并调用 GetController 中的 _startRecieve 方法。正在调用 NSStream
委托,但事件为 NSStreamEventErrorOccurred
。
我调查了一下这个错误,它是 kCFErrorDomainCFNetwork 错误 200,也就是 kCFFTPErrorUnexpectedStatusCode。
由于代码 _startRecieve
代码是相同的,我能想到的唯一问题是它包含在 NSOperation
中。唯一看起来可能与操作 _startRecieve
相关的问题是这样的。
self.networkStream.delegate = self;
[self.networkStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[self.networkStream open];
有什么想法为什么这不起作用吗?
谢谢, 罗斯
I am trying to download a file from an FTP server using an NSOperation. My base example for the download is Apple's Simple FTP project. In particular, I am using the code from the GetController
class. The URL that I am trying to download works fine from there.
In my NSOperation
subclass, I override the start method and call the _startRecieve
method found in GetController
. The NSStream
delegate is getting called, but the event is NSStreamEventErrorOccurred
.
I investigated the error a bit, and it is kCFErrorDomainCFNetwork
error 200, which is kCFFTPErrorUnexpectedStatusCode
.
Since the code _startRecieve
code is identical, the only problem that I can think of would be the fact that it is contained in an NSOperation
. The only thing that looks like it could have problems with an operation _startRecieve
is this.
self.networkStream.delegate = self;
[self.networkStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[self.networkStream open];
Any ideas why this is not working?
Thanks,
Ross
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与其为网络滚动自己的 NSOperation 子类,为什么不使用 Apple 的 MVCNetworking 项目?
Instead of rolling your own NSOperation subclass for networking, why not use QHTTPOperation from Apple's MVCNetworking project?