How to find size of a file before downloading it in iOS 7?

前端 未结 7 1712
天涯浪人
天涯浪人 2020-12-02 00:43

Wanted to find size of a file on some server before downloading it in iOS 7... I have a method of NSURLConnectionDelegate but it is deprecated after iOS 4.3

Here was

7条回答
  •  长情又很酷
    2020-12-02 01:12

    you can use this method,NSURLResponse object which is passed to the following delegate methods:

    -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
    
    }
    -(NSURLRequest *)connection:(NSURLConnection *)connection
            willSendRequest:(NSURLRequest *)request
           redirectResponse:(NSURLResponse *)response {
    }
    

    try like this..

    long long size = [response expectedContentLength];
    

提交回复
热议问题