swift - EXC_BAD_ACCESS on accessing NSButton subclass property from view controller -


i'm attempting access nsbutton subclass property view controller, receive following error @ hoverbutton's setimages method:

exc_bad_access (code=1, adress=0x0)

it seems i'm losing reference, i'm not sure how maintain reference. (still fresh swift & os x dev)

in view controller:

@iboutlet weak var newaccountbutton: hoverbutton! @iboutlet weak var joinaccountbutton: hoverbutton! ... let off = nsimage(named: "button-off")! let on = nsimage(named: "button-over")! newaccountbutton.setimages(imageoriginal: off, imagehover: over) joinaccountbutton.setimages(nscolor.clearcolor(), imageoriginal: off, imagehover: over) 

...

class hoverbutton: nsbutton {      var trackingarea:nstrackingarea!     var hoverbackgroundimage: nsimage!     var originalbackgroundimage: nsimage!       override init(frame framerect: nsrect) {          super.init(frame: framerect)          // set tracking area         trackingarea = nstrackingarea(rect: bounds, options: [nstrackingareaoptions.mouseenteredandexited, nstrackingareaoptions.activealways], owner: self, userinfo: nil)         self.addtrackingarea(trackingarea)      }      required init?(coder: nscoder) {         super.init(coder: coder)          // set tracking area         trackingarea = nstrackingarea(rect: bounds, options: [nstrackingareaoptions.mouseenteredandexited, nstrackingareaoptions.activealways], owner: self, userinfo: nil)         self.addtrackingarea(trackingarea)     }      override func drawrect(dirtyrect: nsrect) {         super.drawrect(dirtyrect)     }      override func mouseentered(theevent: nsevent) {         let cell = self.cell as! nsbuttoncell         cell.image = hoverbackgroundimage      }      override func mouseexited(theevent: nsevent) {         let cell = self.cell as! nsbuttoncell         cell.image = originalbackgroundimage     }      func setimages(imageoriginal: nsimage, imagehover: nsimage) {         self.originalbackgroundimage = imageoriginal         self.hoverbackgroundimage = imagehover     }  } 

based off https://github.com/swift-kit/jzhovernsbutton (use of gives same error)

the problem have no outlets hoverbutton instances in nib or storyboard newaccountbutton , joinaccountbutton properties.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -