How to Using ASIHTTPRequest to tracking Upload/Download progress

守給你的承諾、 提交于 2019-11-28 04:05:48

问题


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

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]

It says :myProgressIndicator is an NSProgressIndicator.

But it looks like Apple deprecated 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 ~


回答1:


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

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

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

  • 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
  • If you want to do both of these at the same time, this is possible too (as of v0.97)

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




回答2:


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.

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



来源:https://stackoverflow.com/questions/4602812/how-to-using-asihttprequest-to-tracking-upload-download-progress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!