So, I just spent a bunch of time trying to figure out what was going on with an NSView subclass whose keyDown() method wasn't doing what it was supposed to be doing. As usual, the Swift debugger was out to lunch, so I put a print at the beginning of my method just to see if the thing was firing at all:
override func keyDown(event: NSEvent) {
print ("WHY IS THIS NOT GETTING CALLED")
...
}Sure enough, the log never showed up in the console, which suggested that my method wasn't being called, and also, when I typed any key, the Print dialog was opening up, suggesting that the key event was getting mangled into the system thinking it was a ⌘P key event. Well, a bunch of event dispatch debugging later, I facepalmed when I realized what was going on:
NSView declares an IBAction method called print(), with its Sender argument as an AnyObject.
My attempt to call the system "print" function resulted in calling self.print() instead, because the Swift compiler thinks it's just too **** hard to just type the self. when you want to call an instance method or get a property.
Grr.