What does “Receiver type 'CALayer' for instance message is a forward declaration” mean here?

强颜欢笑 提交于 2019-12-04 07:46:22

问题


I'm porting a block of code from an iOS4 project to iOS5 and I'm having some troubles with ARC. The code generates a PDF from a screen capture.

PDF Generation Code

UIView *captureView;
...
NSMutableData *pdfData = [NSMutableData data];
UIGraphicsBeginPDFContextToData(pdfData, captureView.bounds, nil);
UIGraphicsBeginPDFPage();
CGContextRef pdfContext = UIGraphicsGetCurrentContext();
[captureView.layer renderInContext:pdfContext];
UIGraphicsEndPDFContext();

The renderInContext line

[captureView.layer renderInContext:pdfContext];

generates the following error.

Automatic Reference Counting issue
Receiver type 'CALayer' for instance message is a forward declaration

Any ideas what is going on here?


回答1:


I was able to duplicate your problem. This is what fixed it for me.

Add QuartzCore.framework to your project and this line to your .m file.

#import <QuartzCore/QuartzCore.h>


来源:https://stackoverflow.com/questions/7813379/what-does-receiver-type-calayer-for-instance-message-is-a-forward-declaration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!