第一个方法是 数据的总进度。
第二个方法是 数据的下载进度。
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
if(httpResponse && [httpResponse respondsToSelector:@selector(allHeaderFields)]){
NSDictionary *httpResponseHeaderFields = [httpResponse allHeaderFields];
double total_ = [[httpResponseHeaderFields objectForKey:@"Content-Length"] longLongValue];
NSLog(@"%f", total_);
}
}
#pragma mark NSURLConnection (delegate)
- (void)connection:(NSURLConnection *)aConnection didReceiveData:(NSData *)data
{
[imageData appendData:data];
double a = [imageData length];
double total = [data length];//总大小还不知道
NSLog(@"这里是加载数据的过程");
NSLog(@"当前数据长度为 = %f", a);
// [imageData appendData:data];
}