如何使用ASIHTTPRequest跟踪上传/下载进度

时间:2021-07-14 10:13:52

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

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

This is the sample from ASIHTTPRequest website

这是来自ASIHTTPRequest网站的样本

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

It says :myProgressIndicator is an NSProgressIndicator.

它说:myProgressIndicator是一个NSProgressIndicator。

But it looks like Apple deprecated NSProgressIndicator

但看起来苹果不赞成使用NSProgressIndicator

Check Here

检查一下

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?) ?

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

Many thanks ~

非常感谢〜

2 个解决方案

#1


5  

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

正如文档所说,代理也可以是iphone / ipad的UIProgressView:

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

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

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:.

进度代表可以是NSProgressIndicators(Mac OS X)或UIProgressViews(iPhone)。 ASIHTTPRequest将自动满足这两个类行为的差异。如果需要,您也可以使用自定义类作为进度委托,只要它响应setProgress:。

  • If you are performing a single request, you set an upload and/or download progress delegate on that request
  • 如果您正在执行单个请求,请在该请求上设置上载和/或下载进度委托
  • If you are performing multiple requests in a queue, and you want to track overall progress for all requests in the queue, use a ASINetworkQueue and set the progress delegate of the queue
  • 如果要在队列中执行多个请求,并且要跟踪队列中所有请求的总体进度,请使用ASINetworkQueue并设置队列的进度委托
  • If you want to do both of these at the same time, this is possible too (as of v0.97)
  • 如果你想同时做这两件事,也可以这样做(截至v0.97)

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

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

#2


1  

Only certain methods of NSProgressView are deprecated. Specifically -animate, -animationDelay, and -setAnimationDelay. They changed how you use the class, they didn't deprecate the whole class.

仅推荐使用NSProgressView的某些方法。特别是-animate,-animationDelay和-setAnimationDelay。他们改变了你使用类的方式,他们没有弃用整个类。

Also, with the tags you chose for your question, you probably want UIProgressView, which is the iPhone version.

此外,使用您为问题选择的标签,您可能需要UIProgressView,这是iPhone版本。

#1


5  

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

正如文档所说,代理也可以是iphone / ipad的UIProgressView:

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

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

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:.

进度代表可以是NSProgressIndicators(Mac OS X)或UIProgressViews(iPhone)。 ASIHTTPRequest将自动满足这两个类行为的差异。如果需要,您也可以使用自定义类作为进度委托,只要它响应setProgress:。

  • If you are performing a single request, you set an upload and/or download progress delegate on that request
  • 如果您正在执行单个请求,请在该请求上设置上载和/或下载进度委托
  • If you are performing multiple requests in a queue, and you want to track overall progress for all requests in the queue, use a ASINetworkQueue and set the progress delegate of the queue
  • 如果要在队列中执行多个请求,并且要跟踪队列中所有请求的总体进度,请使用ASINetworkQueue并设置队列的进度委托
  • If you want to do both of these at the same time, this is possible too (as of v0.97)
  • 如果你想同时做这两件事,也可以这样做(截至v0.97)

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

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

#2


1  

Only certain methods of NSProgressView are deprecated. Specifically -animate, -animationDelay, and -setAnimationDelay. They changed how you use the class, they didn't deprecate the whole class.

仅推荐使用NSProgressView的某些方法。特别是-animate,-animationDelay和-setAnimationDelay。他们改变了你使用类的方式,他们没有弃用整个类。

Also, with the tags you chose for your question, you probably want UIProgressView, which is the iPhone version.

此外,使用您为问题选择的标签,您可能需要UIProgressView,这是iPhone版本。