码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2014-05-01 16:01:00      阅读:306      评论:0      收藏:0      [点我收藏+]

标签:blog   class   code   string   文件   html   set   cti   htm   http   line   

原文来自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];
}

  

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

复制代码

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

 

获取要下载文件的大小信息,码迷,mamicode.com

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

标签:blog   class   code   string   文件   html   set   cti   htm   http   line   

原文地址:http://www.cnblogs.com/luenmicro/p/3700623.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!