开发者

Asynchronous downloads in iPhone

开发者 https://www.devze.com 2023-03-18 12:10 出处:网络
I can able to download a file when an URL is given using the delegate methods of NSURLConnection. When a download is active, its download progress like percentage downloaded, transfer rate, bytes rece

I can able to download a file when an URL is given using the delegate methods of NSURLConnection. When a download is active, its download progress like percentage downloaded, transfer rate, bytes received are shown in the UITableView. So, when I initiate a download, the first cell of the table is active till the download completes. Everything is perfect for a single download.

My problem is, I have no idea how to handle multiple asynchronous downloads. If the URL is given when a download is active, the second cell of the table should be activated and the progress should be shown. I surfed many blogs and forums regarding this. Many suggested to use ASIHTTPRequest. But I am trying to handle the NSURLConnections in an array and hit the requests. When I tried, the first active download is overridden by the second request开发者_运维问答.

Please help me with some ideas to deal this problem using array, without ASIHTTPRequest. Thank you in advance.


Assuming that you're making multiple NSURLConnection objects, one per request just store the connection that each table view cell is referring to in an array.

Then, when the delegate methods are called, they should all pass back the connection object that they are referring to i.e. connection:didReceiveData:'s connection parameter.

You can use this parameter to work out which table cell this delegate call is referring to.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号