NSColorWell color property is nil

270 Views Asked by At

I am trying to set the color of an NSView's layer to the color of an NSColorWell. Please consider my code:

-(void)mouseDown:(NSEvent *)theEvent{

    self.layer.backgroundColor = self.colorWell.color.CGColor;

    NSLog(@"%@",self.colorWell.color.CGColor);
}

colorWell is declared as an IBOutlet and I have assured it is connected in Interface Builder. I noticed the color wasn't changing on mouseDown:, so I added the NSLog() line to log the color coming in from the NSColorWell. I get: (null) in the console. I'm not sure what could be going wrong with such a seemingly simple task. Does anyone have any ideas?

EDIT: I have logged the value of the colorWell itself and the result is (null). Why can I clearly see it as connected in Interface Builder? Also, when I moved the IBOutlet from my NSView subclass to the AppDelegate and added a different connection, I do not get a null value.

0

There are 0 best solutions below