Anthony Kong
Anthony Kong

Reputation: 40664

Customised UIView compliation error message

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?

Upvotes: 1

Views: 959

Answers (2)

Max Seelemann
Max Seelemann

Reputation: 9364

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

Upvotes: 7

samkass
samkass

Reputation: 5951

#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.

Upvotes: 1

Related Questions