I implement a customized class with NSCache to cache some article
i found a problem, that is while hit the home button on simulator, the cached data seems gone
it will load the data from network but not the cache
if not hit home button, it will fetch data from NSCache
ie. My Cache Code:
#import "ArticleCache.h"
@implementation ArticleCache
static NSCache *Cache;
+ (void)initialize
{
[super initialize];
Cache = [[NSCache alloc] init];
[Cache setCountLimit: 1000];
}
+ (void)cacheResponse:(NSData *)response forURL:(NSURL *)URL
{
[Cache setObject:response forKey:URL];
}
+ (NSData *)cachedResponseForURL:(NSURL *)URL
{
return [Cache objectForKey:URL];
}
@end
// don't you guys found that this question just like a poem at least the last char and first char of each line are same.