views:

137

answers:

2

Hi All,

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

+7  A: 

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.

Ben S
>I suspect NSURLResponseUnknownLength is -1.Yep. See the bottom of http://developer.apple.com/mac/library/documentation/cocoa/Reference/Foundation/Classes/NSURLResponse_Class/Reference/Reference.html.
Dewayne Christensen
Thanks for the reference. I fished around a bit to find it, but the Apple search didn't help me.
Ben S
A: 

Could you please let me know the result using "long int" ? If it also returns -1, the cause of the problem exists other point.

To solve the problem, I'd like to know it.

KatokichiSoft