0

我有一个相当简单的问题。如何在 Caches 目录中打开 PDF 文件?

我唯一的代码是在应用程序包中打开一个 PDF 文件。

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

我认为这很容易做到,但我无法弄清楚。谢谢。

4

1 回答 1

1

您可以尝试以下方法:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachePath = [paths objectAtIndex:0];
NSURL *fileURL = [NSURL fileURLWithPath:[cachePath stringByAppendingPathComponent:@"Matsedl.pdf"]];
于 2012-01-07T22:18:35.877 回答