Graphics Programs Reference
In-Depth Information
Therefore, you may want to selectively cache data or just remove built-in caching alto-
gether. To do this, you create a subclass of NSURLCache and override
storeCachedResponse:forRequest: .
@implementation BNRURLCache
- (void)storeCachedResponse:(NSCachedURLResponse *)cachedResponse
forRequest:(NSURLRequest *)request
{
// If the file isn't a pdf, store it as normal, otherwise, ignore it
if (![[[request URL] pathExtension] isEqualToString:@"pdf"])
[super storeCachedResponse:cachedResponse forRequest:request];
}
@end
If you wanted to entirely remove caching, you would override this same method and not
enter any code in the body.
Then, when your application starts up, you tell NSURLCache that the default caching ob-
ject is an instance of your subclass.
BNRURLCache *uc = [[BNRURLCache alloc] init];
[NSURLCache setSharedURLCache:uc];
Search WWH ::




Custom Search