Getting undeclared identifiers when subclassing C4Shapes (C4 Framework)

Im makes a C4 program, which consists of three separate buttons that change their shape when pressed. When I create a bunch of methods for each button, for example:

@implementation MyButton

-(void)methodA {
    C4Log(@"methodA");
    [button1 ellipse:CGRectMake(centerPos.x - buttonWidth/2.0f, 80, buttonWidth, buttonHeight)];
}

-(void)methodB {
    C4Log(@"methodB");
    [button2 ellipse:CGRectMake(centerPos.x - buttonWidth/2.0f, centerPos.y - buttonHeight/2.0f, buttonWidth, buttonHeight)];
}

-(void)methodC{
    C4Log(@"methodC");
    [button3 ellipse:CGRectMake(centerPos.x - buttonWidth/2.0f, canvasHeight - 280, buttonWidth, buttonHeight)];
}

@end

... and then call them in the canvas ...

[button1 listenFor:@"touchesBegan" fromObject:button1 andRunMethod:@"methodA"];
[button2 listenFor:@"touchesBegan" fromObject:button2 andRunMethod:@"methodB"];
[button3 listenFor:@"touchesBegan" fromObject:button3 andRunMethod:@"methodC"];

... All I get is a bunch of unannounced identifier errors. What am I doing wrong?

+3
source share
1 answer

I will need to see a copy of the variables that you defined in the MyButton.h file, but as far as I can tell from your error and your code, the following line calls ivars:

[button1 ellipse:CGRectMake(centerPos.x - buttonWidth/2.0f, 80, buttonWidth, buttonHeight)];

Ivarians centerPos, buttonWidth and buttonHeight must be defined in your .h file, if one of them is not declared there, then you will encounter such an error.

+2
source

All Articles