Note that there are some explanatory texts on larger screens.

plurals
  1. POASIHTTPRequest Caching Not working
    primarykey
    data
    text
    <p>I'm not getting cached results using the ASIHTTPRequest Cache functionality. I followed the directions from documentation. When I have internet access, the below works perfectly. At that point, I will turn on Airplane mode and close the app from multi-tasking. When i do this, I get no asynchronous call to requestFinished. I have tried a bunch of the caching policies but that doesn't seem to do it. Does anyone have any ideas? </p> <p>Goal: To be able to get a cached JSON response with no internet connection (after successfully loading from internet once). </p> <pre><code>- (void)viewDidLoad { if (!networkQueue) { networkQueue = [[ASINetworkQueue alloc] init]; } [networkQueue reset]; [networkQueue setRequestDidFinishSelector:@selector(imageFetchComplete:)]; [networkQueue setRequestDidFailSelector:@selector(imageFetchFailed:)]; [networkQueue setShowAccurateProgress:true]; [networkQueue setDelegate:self]; //Turn on default caching [ASIHTTPRequest setDefaultCache:[ASIDownloadCache sharedCache]]; [self loadData]; [super viewDidLoad]; } -(IBAction)loadData { NSURL *url = [NSURL URLWithString:@"http://SOME_JSON_URL"]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setDelegate:self]; [request setCacheStoragePolicy:ASICachePermanentlyCacheStoragePolicy]; [request startAsynchronous]; } - (void)requestFinished:(ASIHTTPRequest *)request { if ([request didUseCachedResponse]) { NSLog(@"Did use cache!"); } NSString *responseString = [request responseString]; NSLog(@"%@", responseString); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload