I'm trying to follow along with the guides and I thought I would be creating a rectangle with the following code in my DrawBox.m:
However, I get an error pertaining to the use of 'context.' It says it is undeclared but I'm not sure where to declare it or how. Should I declare it in DrawBox.h? The guides are confusing me even more so, so hopefully one of you could help me and I can continue on my way of learning?
Thanks!
P.S. I am fairly new to Objective-C and I know a lot of Java and Python, so if anyone could show me a little bit of what I'm doing in Java with declaring context that would be great, too.
Code:
- (void)drawRect:(CGRect)rect {
// Drawing code here.
CGContextRef myContext = UICurrentContext();
CGRect ourRect = CGRectMake(40, 40, 240, 120);
CGContextSetRGBFillColor(context, 0.0,0.0,1.0,1.0);
CGContextFillRect(context, ourRect);
CGContextSetRGBStrokeColor(context, 0.0, 1.0, 0.0, 1.0);
CGContextStrokeRectWithWidth(context, ourRect, 10);
}
However, I get an error pertaining to the use of 'context.' It says it is undeclared but I'm not sure where to declare it or how. Should I declare it in DrawBox.h? The guides are confusing me even more so, so hopefully one of you could help me and I can continue on my way of learning?
Thanks!
P.S. I am fairly new to Objective-C and I know a lot of Java and Python, so if anyone could show me a little bit of what I'm doing in Java with declaring context that would be great, too.