开发者

How to implement offline reading in my app

I would like to implement offline reading for a news application I have been developing on the iphone. I currently use SDURLCache and I can see the con开发者_Go百科tent is loaded from the disk but how can I find if there is already something in the cache for the given url without starting a new url connection?

or if there is some other way to do that please let me know.

thx


You might be able to 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];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜