使用 NSOperation 下载和 FTP 文件

发布于 2024-11-17 13:46:59 字数 889 浏览 4 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眉目亦如画i 2024-11-24 13:46:59

与其为网络滚动自己的 NSOperation 子类,为什么不使用 Apple 的 MVCNetworking 项目?

Instead of rolling your own NSOperation subclass for networking, why not use QHTTPOperation from Apple's MVCNetworking project?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文