首页 > 代码库 > 获取要下载文件的大小信息
获取要下载文件的大小信息
原文来自IOS教程网,转载时请注明文章的来源:http://ios.662p.com/thread-1660-1-1.html
NSURLConnectionDataDelegate方法中有:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 | -( 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教程网了解一下。
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。