1

I have this code, and it is working exactly as desired:

UIGraphicsBeginImageContext(self.bounds.size);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage* image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();   

However, for this line:

[self.layer renderInContext:UIGraphicsGetCurrentContext()];

I am getting the warning (not error):

No '-renderInContext' method found.

How can I have this warning, if in fact the method is working? If I were to simply comment out this line, my code fails; so clearly the line, and thus the method, are in fact working.

jscs
  • 63,694
  • 13
  • 151
  • 195
johnbakers
  • 24,158
  • 24
  • 130
  • 258

3 Answers3

7

You need to add reference to the header file for CALayer - #import <QuartzCore/QuartzCore.h>. You might also need to add the QuartzCore.framework to your project.

Deepak Danduprolu
  • 44,595
  • 12
  • 101
  • 105
Jiri
  • 2,206
  • 1
  • 22
  • 19
3

It's saying this because the compiler can't find the definition of that method. You need to add this line:

#import <QuartzCore/QuartzCore.h>

to the start of the .m file. You may also need to add the QuartzCore framework to your project.

(the reason your app works is that the method is available at run time)

grahamparks
  • 16,130
  • 5
  • 49
  • 43
0

You are probably having the same issue as this guy. Make sure you add QuartzCore.

Community
  • 1
  • 1
Joe
  • 56,979
  • 9
  • 128
  • 135