I'm working with the C4 framework on a project and I'm having a bit of trouble with using the gesture controls and calling methods from C4WorkSpace.
I found this link that had to do with this problem but it didn't seem to stop my program from throwing an error.
A little background: I'm creating a custom button class that has 4 properties: UIColor, C4Shape and 2 floats (x/y position). I'm storing the custom button objects in an array and have this bit of code going to add a gesture to each button and add it to the canvas.
C4WorkSpace.m
for (button in buttonArray){ [button.shape addGesture:TAP name:@"tapGesture" action:@"tapped"]; [self.canvas addShape:button.shape]; [self listenFor:@"tapped" fromObject:button andRunMethod:@"doThis:"]; } And I also have a function outside my '-(void)setup' that just prints a log message:
-(void)doThis:(NSNotification *)notification{ NSLog(@"notification test"); } I have extended my C4Shape class with a category and when I call this method it works fine:
#import "C4Shape+myC4Shape.h" @implementation C4Shape (myC4Shape) -(void)printTest{ NSLog(@"this is a print test"); } @end The error I'm getting gets thrown when I try and tap on a button, it says: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[C4Shape tapped]: unrecognized selector sent to instance 0x931e9c0'
I have my "action" set to 'tapped', but that's just something I made up. I know this usually calls a method inside the shape class, but I'm trying to call a method that isn't in the C4Shape class but on the main WorkSpace. I'm not sure what's causing this or what I'm doing wrong? Is there something specific I need to be writing in the 'action' part of the method?