Multiple NSURLConnection
I am downloading a file using NSURLConnection for the given URL. When the download is in progress, I need to display some information about the downloading file in the tableView. I have designed an UI with UIProgressView and some required labels. Initially the the number of active rows in the tableView should be 0. When a download starts, the first cell should be active and update the information. Actually, I have the required information to be updated. But I have no idea how to make it active when the download is in progress.
The next place where I have struck is, when one download is in progress, how to start a new download without disturbing the current download, and it has to be updated in the second cell of the tableView. Should I use开发者_开发问答 NSMutableArray to store the request and deal it one by one? Help me to come out of the two problems. Thank you in advance.
1) You can use custom view for displaying loading indicator and label, and hide tableview when requesting to server and unhide tableview at time of connectionDidFinishLoading or response come and hid custom view...
2) You can make more than one request to server at a time using following code,
connectionFirst = [[NSURLConnection alloc]initWithRequest:requestFirst delegate:self];
connectionSecond = [[NSURLConnection alloc]initWithRequest:requestSecond delegate:self];
and in ConnectionDidFinsihLoading delegate method, you can check this connection object, to make it unique.
if(connection == connectionFirst){
//This is your first connection response
}
else if(connection == connectionSecond){
//This is your second connection response
}
精彩评论