How to load a PDF from the Caches directory?

1.2k Views Asked by At

I have a rather simple question. How do I open a PDF-file in the Caches directory?

The only code I have is to open a PDF-file in the application bundle.

myDocumentRef = CGPDFDocumentCreateWithURL((CFURLRef)[NSURL URLWithString:@"Matsedel.pdf"]);
NSURL *pdfURL = [[NSBundle mainBundle] URLForResource:@"Matsedel.pdf" withExtension:nil];
myDocumentRef = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
myPageRef = CGPDFDocumentGetPage(myDocumentRef, 1);

I would assume that this is quite easy to do but I can't figure it out. Thanks.

1

There are 1 best solutions below

0
On BEST ANSWER

you can try something like:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachePath = [paths objectAtIndex:0];
NSURL *fileURL = [NSURL fileURLWithPath:[cachePath stringByAppendingPathComponent:@"Matsedl.pdf"]];