2012-01-07 59 views
0

我有一個相當簡單的問題。如何在Caches目錄中打開PDF文件?如何從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); 

我會認爲這很容易做,但我無法弄清楚。謝謝。

回答

1

你可以嘗試這樣的:

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