开发者

CGPDFDocumentRef and autorelease

Is there an autorelease analogous method for CG开发者_运维知识库PDFDocumentRef instances? I'd like to apply this before returning an instance I created. Or can I only do CGPDFDocumentRelease(...) before returning (which is surely wrong)?

Since I created the CGPDFDocumentRef I'd like to take care with its release.


The best thing you can do is to write an Obj-C wrapper around CGPDFDocumentRef and release the CGPDFDocumentRef on your wrapper's dealloc method so the rest of your code will retain/release your wrapper as with ay other NSObject derivate and once the wrapper's retain count reaches zero the CGPDFDocumentRef will be released on the wrapper's dealloc method and consequently freed from memory as it's retain count never got past 1.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜