문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top