CGPDFDocumentRelease() 使应用程序崩溃,错误地表示已释放

发布于 2024-10-01 12:39:42 字数 498 浏览 0 评论 0原文

我正在为 iOS 编写一个 PDF 查看器。当我初始化我的视图控制器时,我获得了对pdf的引用,

pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);

然后我在该类的整个生命周期中使用它来获取CGPDFPageRef之类的,

CGPDFPageRef pageRef = CGPDFDocumentGetPage(pdf, docPage);

子视图控制器使用这些页面并在释放时释放它们。但是,当我尝试发布 pdf 本身(使用 CGPDFDocumentRelease)时,出现以下错误:

[Not A Type release]: message sent to deallocated instance

这是怎么回事?这不是问题,但我的堆快照分析充满了 CG 对象和大量分配,所有这些似乎都与 pdf(单个页面)内容流相关。

I am writing a PDF viewer for iOS. I obtain a reference to the pdf when I initialize my viewcontroller like,

pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);

Then I use it throughout the life of that class to obtain CGPDFPageRef's like,

CGPDFPageRef pageRef = CGPDFDocumentGetPage(pdf, docPage);

The child view controllers use these pages and release them when dealloc'd. However, when I attempt to release the pdf itself (with CGPDFDocumentRelease), I get the following error:

[Not A Type release]: message sent to deallocated instance

What is up with that? It wouldn't be a problem, but my heapshot analysis is packed with CG objects and a massive allocation that all seems to correlate with the pdf (individual pages) content stream.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最笨的告白 2024-10-08 12:39:42

如果您没有保留 pageRef,则不得释放它。即使您保留了它,如果文档本身被释放,它也可能无法使用。因此,您可能需要在子视图控制器中保留页面和文档,并相应地释放它们。

You must not release pageRef if you did not retain it. Even if you retained it, it might not be usable if the document itself was deallocated. So you might need to retain both the page and the document in your child view controllers, and release them accordingly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文