gpt4 book ai didi

ios - NSURLSessionConfiguration 和 NSMutableURLRequest 缓存策略的区别

转载 作者:可可西里 更新时间:2023-11-01 01:32:17 42 4
gpt4 key购买 nike

我正在使用代码:

let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
configuration.requestCachePolicy = NSURLRequestCachePolicy.ReloadIgnoringLocalCacheData
let session = NSURLSession(configuration: configuration)
let request = NSMutableURLRequest(URL: url)
request.cachePolicy = NSURLRequestCachePolicy.ReloadIgnoringLocalCacheData
request.HTTPMethod = "POST"
request.HTTPBody = bodyData
let dataTask = session.dataTaskWithRequest(request) { (data: NSData?, response: NSURLResponse?, error: NSError?) in
//...
}

我想知道这两个之间有什么区别,必须使用哪个。

configuration.requestCachePolicy = NSURLRequestCachePolicy.ReloadIgnoringLocalCacheData
request.cachePolicy = NSURLRequestCachePolicy.ReloadIgnoringLocalCacheData

谢谢。

最佳答案

NSURLSessionConfiguration sets the properties at NSURLSession which can be overridden by NSURLRequest object.

正如这里的回答: https://stackoverflow.com/a/33316897/3238178

关于ios - NSURLSessionConfiguration 和 NSMutableURLRequest 缓存策略的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39106541/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com