I want to cache my PDF data (displayed using UIWebView) for improved app performance. I can't seem to find a working code or maybe it's just my code that doesn't work. My cache always returns NULL.
I have two viewcontrollers: NavigatePDFViewController and PDFViewController. The NavigatePDFViewController displays a list of PDF titles in which when clicked, opens a PDF file from the internet. The PDFViewController displays the PDF file.
Here are the steps I've done:
1) Added the NSCacheDelegate on my PDFViewController
2) Created an instance of NSCache like this. I created NSCache *cache in the NavigatePDFViewController.h.
cache = [[NSCache alloc]init];
[cache setDelegate:self];
3) Added an object on my cache like this. receivedData is an NSMutableData and link is an NSString.
[cache setObject:receivedData forKey:link];
4) When I check the content of my cache using the code below, it returns null.
[cache objectForKey:link]
What am I missing? Any help would be much appreciated.