views:

20

answers:

2

Here is a code fragment

#import "MyCustomView.h"


@implementation MyCustomView

-(void) drawRect:(CGRect)rect {
    NSLog(@"Help");
    CGContextRef myContext = [[NSGraphicsContext // 1

                               currentContext]graphicsPort];

....

Then at 1, I encountered this error message:

NSGraphicsContext undeclared (first use in this function)

Do you have any idea what caused it? Any header file I should include?

+1  A: 

#import <UIKit/UIKit.h> (usually done in the .h file) should do it as long as you haven't removed the UIKit Framework from your project.

samkass
+1  A: 

On iOS you have to use UIGraphicsGetCurrentContext() to get the current CGContext. Your call is valid on Mac OS.

Max Seelemann