【发布时间】:2013-03-30 00:50:00
【问题描述】:
我有一个需要注释 pdf 的应用程序。我一直在使用来自how to edit a PDF in objective-c? 的代码,它很棒,除了文件位置部分。我正在使用
获取 pdfNSString *newFilePath = [[NSBundle mainBundle] pathForResource:@"Untitled_4" ofType:@"pdf"];
这在模拟器中有效,但在我的测试 iPad 上无效。
我收到了这个错误:
CGDataConsumerCreateWithFilename: failed to open 'long boring file path' for writing: Operation not permitted.
我也玩过
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *newFilePath = [documentsDirectory stringByAppendingPathComponent:@"Untitled_4.pdf"];
我现在明白“您不能写入应用程序包”。谢谢The operation couldn’t be completed. Operation not permitted
当我稍后尝试打开新的带注释的 pdf 时,它无法正确打开。
任何帮助将不胜感激。你们摇滚!
希望这将帮助所有在 iOS 中需要 pdf 注释帮助的其他人。
【问题讨论】:
-
你NSLog变量newFilePath了吗?
-
是的,我做到了。它返回了我在上面称为“长无聊文件路径”的相同长字符串
-
具体来说是“/var/mobile/Applications/EFEF65E1-5D45-4720-A2D8-3B3AFE04D2E5/TeacherTableView4.app/Untitled_4.pdf”
标签: ios pdf annotations directory bundle