获取要下载文件的大小信息

王朝学院·作者佚名  2016-08-27
窄屏简体版  字體: 小  |  中  |  大  |  超大  

原文来自IOS教程网,转载时请注明文章的来源:http://ios.662p.com/thread-1660-1-1.html

NSURLConnectionDataDelegate方法中有:

-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response

{

//This method is called when the server has determined that it

//has enough information to create the NSURLResponse.

//It can be called multiple times, for example in the case of a

//redirect, so each time we reset the data.

//receivedData is an instance variable declared elsewhere.

NSLog(@"要下载文件大小为 %lld",response.expectedContentLength);

[self.receivedData setLength:0];

}

//在此方法中可以更新进度条 -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{ //PRovide an indication of the connection's progress to the user. //progressView.progress = [self.receivedData length] / totalSize [self.receivedData appendData:data];}

复制代码

大家如果有什么ios开发的问题,可以到ios教程网了解一下。

 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝網路 版權所有 導航