How to implement offline reading in my application

I would like to implement offline reading for the news application that I was developing on iphone. I am currently using SDURLCache and I can see that the content is loading from disk, but how can I find out if there is something in the cache for this URL without starting a new connection with the URL?

or if there is any other way to do this, please let me know.

THX

+3
source share
1 answer

Perhaps you can do this:

NSData* cacheForUrl(NSString *aUrl) {
  SDURLCache *cache = [[SDURLCache alloc] init]; 
  NSCachedURLResponse *response = [cache cachedResponseForRequest:[NSUrlRequest requestWithURL:aUrl];
  if(!response) {
    return @"URL not in cache";
  } //implicit else

  return [response data];
}
+1
source

Source: https://habr.com/ru/post/1786235/


All Articles