You can get the expected total file size in the following callback method of NSURLConnection's NSURLConnectionDataDelegate
:
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
self.expectedTotalSize = response.expectedContentLength;
}
then in following callback method you can calculate how much data has been received:
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
self.recievedData += data.length;
}
And you can use UIProgressView to show current downloading status on the screen.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…