得到了以下錯誤:存儲創建的PDF文件的位置?
CGDataConsumerCreateWithFilename: failed to open `/name' for writing: Permission denied.
有了這個代碼(不是我):
- (void)createPDFWithName
{
//NSURL * newFilePath = [[NSURL alloc] initFileURLWithPath:name];
NSString * newFilePath = @"name";
CGRect page = CGRectMake(0, 0, 300, 300);
NSDictionary * metaData = nil;
if (!UIGraphicsBeginPDFContextToFile(newFilePath, page, metaData)) {
NSLog(@"error creating PDF context");
return;
}
UIGraphicsBeginPDFPage();
[self.tableView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIGraphicsEndPDFContext();
}
所以:我應該在哪裏存儲此PDF文件?我嘗試了NSBundle MainBundle
的事情,它也沒有工作。
謝謝!
的壽命相同感謝您的回答。它不適用於我的類方法?做' - (NSString *)...`就像一個魅力。 – DAS 2011-12-14 11:03:33