我正在创建一个 url 请求,如下所示:
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:1 timeoutInterval:5];
参考缓存策略的开发人员文档,我阅读了以下内容:
enum
{
NSURLRequestUseProtocolCachePolicy = 0,
NSURLRequestReloadIgnoringLocalCacheData = 1,
NSURLRequestReloadIgnoringLocalAndRemoteCacheData =4,
NSURLRequestReloadIgnoringCacheData = NSURLRequestReloadIgnoringLocalCacheData,
NSURLRequestReturnCacheDataElseLoad = 2,
NSURLRequestReturnCacheDataDontLoad = 3,
NSURLRequestReloadRevalidatingCacheData = 5
};
typedef NSUInteger NSURLRequestCachePolicy;
那么声明cachePolicy
for 的正确方法是NSURLRequest
什么?
我应该将其定义为:
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:1 timeoutInterval:5];
或者我应该将其定义为:
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:5];
两者似乎都有效,但一种方法比另一种更好吗?