At runtime, I am creating a NSSlider inside an NSMenu. I would like a message to be sent to a target object, but that message also requires a float argument.
So far, I have managed to do this by keeping a pointer on the NSSlider:
NSSlider * widthSlider = [[NSSlider alloc]
initWithFrame:NSMakeRect(16, 0, 150, 32)];
[widthSlider setMinValue:0.1];
[widthSlider setMaxValue:10];
[widthSlider setTarget:self];
widthSliderRef=widthSlider;
[widthSlider setAction:@selector(updateLW:)];
[...]
-(void) updateLW:(id)sender {
[self setLW:[widthSliderRef doubleValue]]; }
Now I would like to get rid of the widthSliderRef.
I would like the NSSlider to send setLW: to self with its doublevalue as argument.
How can it be done ?
The
senderargument toupdateLW:should be the slider — you can just senddoubleValueto that.