[英]ASIDownLoadCache doesn't work
ASIHTTPRequest *request = [[ASIHTTPRequest alloc]initWithURL:[NSURL URLWithString:url]];
request.requestHeaders = header;
request.requestMethod = @"GET";
request.tag = DBRequestTypeChannelCategory;
[request setDelegate:self];
[request setNumberOfTimesToRetryOnTimeout:2];
[request setDownloadCache:[ASIDownloadCache sharedCache]];
[request setCacheStoragePolicy:ASICachePermanentlyCacheStoragePolicy];
[request setCachePolicy:ASIFallbackToCacheIfLoadFailsCachePolicy];
[request setSecondsToCache:60*60*24*3];
[request startAsynchronous];
這是我關於http的代碼,如果我將手機轉為飛行模型。 我懂了
Error Domain=ASIHTTPRequestErrorDomain Code=1 "A connection failure occurred" UserInfo=0x1fd67bf0 {NSUnderlyingError=0x1fd66bf0 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 2.)", NSLocalizedDescription=A connection failure occurred}
您發布的錯誤表示崩潰是由連接故障引起的,如果啟用了飛行模式,這是有道理的。 您應該能夠通過設置故障處理程序來消除這種情況。
[request setFailedBlock:void^{
//
}];
要么
[request setDidFailSelector:@selector(requestWentWrong:)];
要訪問沒有互聯網訪問的緩存數據,只需將以下內容添加到您的請求中即可。
[request setCachePolicy:ASIFallbackToCacheIfLoadFailsCachePolicy];
為了使它起作用,您需要確保將緩存存儲設置為永久性,以防止在用戶存在應用程序時刪除緩存。
[request setCacheStoragePolicy:ASICachePermanentlyCacheStoragePolicy];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.