Question

I am using this NSURLConnection Delegate method

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
    long long rdata = [response expectedContentLength];
    NSLog(@"Response Length : %lld", rdata);    
}

its always showing -1

What is the format specifier for long long variable ?

Thanks

Was it helpful?

Solution

From the docs on expectedContentLength:

Return Value

The receiver’s expected content length, or NSURLResponseUnknownLength if the length can’t be determined.

NSURLResponseUnknownLength is equals to -1. Have you tried inspecting the content-length header? The server you're connecting to is likely using a chunked transfer encoding, so the content-length is not available.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top