1

I'm having problems with clearing the cache of PSPDFDocument before and after deleting the PDF file.

here's what I do:

// ...
PSPDFDocument *document = [PSPDFDocument PDFDocumentWithUrl:(pdfURL)];
[document clearCacheForced:YES];

[mManagedObjectContext deleteObject:mPdfDocument];
// ...

when I try to clear entire cache for all PDFs, it works:

// ...
[[PSPDFCache sharedPSPDFCache] clearCache];
// ...

Any ideas?

jackal
  • 1,143
  • 17
  • 32

2 Answers2

2

Well, the method name is a bit misleading, clearCacheForced on PSPDFDocument just releases some internal cache like the document page count, coordinates, annotation positions - not image content that is cached to disk by PSPDFCache. You need to call

- (void)removeCacheForDocument:(PSPDFDocument *)aDocument deleteDocument:(BOOL)deleteMagazine

in PSPDFCache to remove the cached images.

Also see the API documentation: http://pspdfkit.com/documentation/Classes/PSPDFCache.html#//api/name/removeCacheForDocument:deleteDocument:

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
steipete
  • 7,581
  • 5
  • 47
  • 81
0

For PSPDFKit 4.1.0 + the [PSPDFCache sharedPSPDFCache] is deprecated, Please use this :

[[PSPDFKit sharedInstance].cache removeCacheForDocument:self.document deleteDocument:YES error:&error];
Saeed
  • 926
  • 16
  • 28