NSView - strange behaviour

I have a custom NSView (Swift) with this draw method

override func draw(_ dirtyRect: NSRect) {
   if let g: CGContext = NSGraphicsContext.current?.cgContext {
      g.setShouldAntialias(false)
      g.setFillColor(self.color.cgColor)
      g.fill(dirtyRect)
      print("fill \(dirtyRect) \(self.color)")
   }
}

It uses the correct color when the object is first intialized, but after that it does not change.
HOWEVER, the print statement shows a new color value each time I expect it to
So the Draw function is being called properly, and the color is the correct color, it just doesn’t update the object as it should…

Anyone got an idea?

Solved. The app has an array of these NSView objects… but in the INIT of each one I had called

colorPanel.setTarget(self)

which left the colorPanel connected only to the LAST object…
I needed to move this to the MouseDown event of the object needed to be changed