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

前端 未结 7 1714
天涯浪人
天涯浪人 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:04

    try this will help . . . . .

    -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse
                                                                          *)response
    {
        NSHTTPURLResponse * pHttpUrlResponse = (NSHTTPURLResponse *) response;
    
        if ([response respondsToSelector:@selector(allHeaderFields)])
        {
            NSString * fileLength = [NSString stringWithFormat:@"%lld",[pHttpUrlResponse expectedContentLength]];
        }    
    }
    

    happy coding :)

提交回复
热议问题