zoukankan      html  css  js  c++  java
  • 获取要下载文件的大小信息

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

      

    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教程网了解一下。

     

  • 相关阅读:
    git 常用命令
    centos 7 mini 安装
    python打印杨辉三角
    python 求100内的素数/质数
    字符串与bytes
    format
    Python字符串格式化
    数据结构
    ARM工作模式
    C语言实现字符串逆序输出
  • 原文地址:https://www.cnblogs.com/luenmicro/p/3700623.html
Copyright © 2011-2022 走看看