如何使用 ASIHTTPRequest 跟踪上传/下载进度 [英] How to Using ASIHTTPRequest to tracking Upload/Download progress

查看:39
本文介绍了如何使用 ASIHTTPRequest 跟踪上传/下载进度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题是使用 ASIHTTPRequest 来跟踪上传/下载进度

I got some question is using ASIHTTPRequest to tracking Upload/Download progress

这是来自 ASIHTTPRequest 网站的示例

This is the sample from ASIHTTPRequest website

ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDownloadProgressDelegate:myProgressIndicator];
[request startSynchronous];
NSLog(@"Max: %f, Value: %f", [myProgressIndicator maxValue],[myProgressIndicator doubleValue]

它说:myProgressIndicator 是一个 NSProgressIndicator.

It says :myProgressIndicator is an NSProgressIndicator.

但看起来 Apple 已弃用 NSProgressIndicator

But it looks like Apple deprecated NSProgressIndicator

检查这里

那么……我怎么知道上传/下载进度???

So ... how can I know the Upload/Download progress ???

还有一个问题是...如果上传/下载在任务完成之前终止

Also another question is ...if the Upload/Download was terminated before the task finish

如何让上传/下载任务从停止点(断点?)开始?

How can I let the Upload/Download task continues start from the stop point(break point?) ?

非常感谢~

推荐答案

正如文档所说,在 iphone/ipad 的情况下,delegate 也可以是 UIProgressView:

As the documentation says, the delegate can also be an UIProgressView in case of iphone/ipad:

每个 ASIHTTPRequest 有两个委托可用于跟踪进度- downloadProgressDelegate(用于下载)和uploadProgressDelegate(用于上传).

Each ASIHTTPRequest has two delegates that can be used for tracking progress - downloadProgressDelegate (for downloads) and uploadProgressDelegate (for uploads).

进度委托可以是NSProgressIndicators (Mac OS X) 或UIProgressViews (iPhone).ASIHTTPRequest 会自动迎合差异这两个类的行为.如果你想要,您也可以使用自定义类作为进度委托,只要它响应 setProgress:.

Progress delegates can be NSProgressIndicators (Mac OS X) or UIProgressViews (iPhone). ASIHTTPRequest will automatically cater for the differences in the behaviour of these two classes. If you want, you can also use a custom class as a progress delegate, as long as it responds to setProgress:.

  • 如果您正在表演单曲请求,您设置上传和/或下载进度委托请求
  • 如果您正在执行多个队列中的请求,并且您想要跟踪所有人的整体进度队列中的请求,使用ASINetworkQueue 并设置进度队列的委托
  • 如果你想同时做这两件事,这也是可能的(从 v0.97 开始)

来源:http://allseeing-i.com/ASIHTTPRequest/How-to-use#tracking_progress

这篇关于如何使用 ASIHTTPRequest 跟踪上传/下载进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆