In your didReceiveResponse function you could get the total filesize like so:
_totalFileSize = response.expectedContentLength;
.
In your didReceiveData function you can then add up to a total bytes received counter:
_receivedDataBytes += [data length];
Now in order to set the progressbar to the correct size you can simply do:
MyProgressBar.progress = _receivedDataBytes / (float)_totalFileSize
(either in the didReceiveData function or somewhere else in your code)
Don't forget to add the variables that hold the number of bytes to your class!
I hope this helps..
EDIT: Here's how you could implement the delegates in order to update progressview
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
_totalFileSize = response.expectedContentLength;
responseData = [[NSMutableData alloc] init];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
_receivedDataBytes += [data length];
MyProgressBar.progress = _receivedDataBytes / (float)_totalFileSize;
[responseData appendData:data];
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…