使用 ASIHTTPRequest 通过 Cocoa/MacRuby 下载文件
我仍在尝试掌握 Cocoa(在 Obj-C 和 MacRuby 中),并且我真的很高兴看到如何使用 ASIHTTPRequest(或不使用它)和 MacRuby 下载文件。理想情况下,我也希望能够在进度栏中显示进度。
必须使用cocoa方法下载,因为MacRuby中的open-uri已损坏。
感谢您的帮助。
I'm still trying to get a handle on Cocoa (both in Obj-C and MacRuby), and I'd really appreciate seeing how to download a file with ASIHTTPRequest (or without it) and MacRuby. Ideally, I'd like to be able show the progress inside a progress bar too.
Must use a cocoa method for downloading, since open-uri in MacRuby is borken.
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
下面是一个使用 HotCocoa 执行此操作的示例应用程序: http://github.com /richkilmer/hotcocoa/tree/master/examples/download_and_progress_indicator
你必须将其转换为普通的Cocoa,但是如果你查看http://github.com/richkilmer/hotcocoa/blob/master/examples/download_and_progress_indicator/lib/application.rb 你会看到定义的主要回调。
您可能想在 MacRuby 邮件中提出问题,以便参与该项目的人员可以提供帮助。
p.s:cocoa IO 方法比 Ruby 的更加稳定和高效。另请记住,您想要执行异步调用,而 net/http 无法帮助您。
Here is an example app doing exactly that using HotCocoa: http://github.com/richkilmer/hotcocoa/tree/master/examples/download_and_progress_indicator
You would have to convert it to normal Cocoa but if you look at http://github.com/richkilmer/hotcocoa/blob/master/examples/download_and_progress_indicator/lib/application.rb you will see the main callbacks defined.
You might want to ask your questions in the MacRuby mailing so people involved with the project can help.
p.s: The cocoa IO methods are way more stable and efficient than Ruby's. Also keep in mind that you want to do async calls, something net/http won't help you with.
以下是我正在写的书中的更多解释和示例: http://macruby .labs.oreilly.com/ch03.html#_urls_requests_connections 希望这会有所帮助。
Here are more explanations and an example from the book I'm writting: http://macruby.labs.oreilly.com/ch03.html#_urls_requests_connections Hopefully that will help.