将timeoutInterval设置为unlimited

时间:2015-09-18 09:58:59

标签: ios swift

我真的不想要一个timeoutInterval,因此在离线时总是可以使用缓存,但我也不能将其删除。有没有办法将其设置为无限制?

var requestObj = NSURLRequest(URL: url!, cachePolicy: NSURLRequestCachePolicy.ReturnCacheDataElseLoad, timeoutInterval: 5);

2 个答案:

答案 0 :(得分:3)

简单

var requestObj = NSURLRequest(URL: url!, cachePolicy: NSURLRequestCachePolicy.ReturnCacheDataElseLoad, timeoutInterval: Double.infinity);

答案 1 :(得分:0)

var requestObj = NSURLRequest(URL:url !, cachePolicy:NSURLRequestCachePolicy.ReturnCacheDataElseLoad,timeoutInterval:Double.greatestFiniteMagnitude)