Question

I have created request as below,

NSURLResponse *response;
NSError *error;

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:JsonURL];
[request setTimeoutInterval:10];

[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

But here time out interval is not working,I checked some questions on stack some said default time out is 75 seconds and some said it's 240 seconds,I am confused here ..

please help me with this.

Was it helpful?

Solution

You are using a synchronous connection. So there will be no calls to a delegate. If you still want to use a synchrous URL request I would recommend the following:

[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

if (nil == response) {
    if (error)
        NSLog(@"Connection failed! Error - %@ %@",
        [error localizedDescription],
        [[error userInfo] objectForKey:NSURLErrorFailingURLStringErrorKey]);
    }
}

If you are want to use the delegate method you have to use an asynchronous request.

Please check the URL Loading System Programming Guide too.

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