swift - Trying to overide NSView's drawRect from extension class -


i designing nsview class extension in swift. inside extension class trying override drawrect using this

extension nsview {     override func drawrect(rect: nsrect) {     } 

there error pointing override , saying method not override method superclass... method drawrect objective-c (???) selector 'drawrect' conflicts previous declaration same objective-c selector

what? objective-c? using swift.

what going on?

you extending not subclassing , overriding method defined superclass.

drawrect defined nsview, that's why conflict already defined ...

in order custom view intended define own subclass of nsview , override subclass's drawrect implementation.

class myview: nsview {      override func drawrect(rect: nsrect) {       // custom implementation ....      }  } 

hope helps


Comments