我在使用带有 Mountain Lion 10.8.4 的 PDFDocument 时遇到了一个奇怪的错误,我无法使用 removePageAtIndex 方法。它总是会崩溃。
代码非常简单
PDFDocument* theOldPDF = [[PDFDocument alloc] initWithURL:[panel URL]];
[theOldPDF pageCount];
NSLog(@"[theOldPDF pageCount] : %lu",[theOldPDF pageCount]);
[theOldPDF removePageAtIndex:1];
NSLog(@"PAGE REMOVED");
以下是文档打开时引发的异常:
2013-06-08 22:05:59.120 test pdf remove crash[3978:303] [theOldPDF pageCount] : 10
2013-06-08 22:05:59.124 test pdf remove crash[3978:303] -[__NSCFNumber annotations]: unrecognized selector sent to instance 0x187
2013-06-08 22:05:59.128 test pdf remove crash[3978:303] An uncaught exception was raised
2013-06-08 22:05:59.128 test pdf remove crash[3978:303] -[__NSCFNumber annotations]: unrecognized selector sent to instance 0x187
2013-06-08 22:05:59.132 test pdf remove crash[3978:303] (
0 CoreFoundation 0x00007fff99048b06 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff920c23f0 objc_exception_throw + 43
2 CoreFoundation 0x00007fff990df40a -[NSObject(NSObject) does NotRecognizeSelector:] + 186
3 CoreFoundation 0x00007fff9903702e ___forwarding___ + 414
4 CoreFoundation 0x00007fff99036e18 _CF_forwarding_prep_0 + 232
5 PDFKit 0x00007fff936e1fde -[PDFDocument removePageAtIndex:] + 408
6 test pdf remove crash 0x00000001000013fc -[AppDelegate openDocument:] + 476
如日志所示,PDF 有 10 页,我尝试删除第一个(或其中任何一个),它会崩溃。
有人已经遇到这种问题了吗?这只发生在 10.8.4 上,到目前为止运行良好。
谢谢