I had a similar problem, but with the NSView class. I was able to make this work as follows. I had to put it in a class outside of any functions.
import Cocoa class MyView: NSView, NSDraggingDestination { //MARK: Variables override var acceptsFirstResponder: Bool { return true } override var opaque: Bool { return true } var bgColor : NSColor = .yellowColor() var lastString : String = "" var attributes : NSMutableDictionary = [:] var highlightNeeded = false
source share