NSURLRequest Timeout IOS

前端 未结 3 1340
误落风尘
误落风尘 2020-12-20 21:57

I need to set timeout 15sec or 30 sec with UIRequest, but it always takes default one. Is there any way to set minimum timeout to connection.

3条回答
  •  感情败类
    2020-12-20 22:33

    There seems to be a problem with setting the timeout interval property at construction time:

    NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:240.0];
    

    Instead set it AFTER construction:

    request.timeoutInterval = 70;

    Also note that there seem to be some limitations to how low you can set the interval. Read this post for more information: https://devforums.apple.com/message/108087#108087

提交回复
热议问题