Adding Action Methods to Controls



I’ve created an NSButton Class and added an Action to it as so:

myButton = [[NSButton alloc] initWithFrame:myButtonFrameRect];
myButton.image = myImage;
myButton.imageScaling = NSImageScaleProportionallyUpOrDown;
self.pCellButton = myButton; = self;
[self.pCellButton sendActionOn:NSEventMaskLeftMouseDown];
[self.pCellButton setAction:@selector(performCellSelected:)];

[self addSubview:self.pCellButton];

-(void) performCellSelected:(id) theSender
NSLog(@"performCellSelected: theSender: %@", theSender.identifier);

This works ok, EXCEPT the parameter pass in “theSender” is nil???? I would have thought it should be the NSButton object that the Action was sent from is this not the case?

All the Best


Ignore this, was a silly bug in that the identifier wasn’t setup correctly!