swift - Trying to access property of a class which subclasses a cocoa class gives run-time error -


i made customized button type(class) inherits nsbutton , has additional methods well, when try access methods declared myself, run-time error. here's code:

import cocoa  class mcbutton: nsbutton {     func testfunc()->bool {         return true     } }  class viewcontroller: nsviewcontroller {     @iboutlet weak var button: mcbutton!      override func viewdidload() {         super.viewdidload()         if button.testfunc() {   //thread 1: exc_bad_access(code=2, address=0x608000264600)             button.title = "hi!"         }     }  } 

note don't have problems when use methods declared in superclass(nsbutton). what's problem? should fix it?

you have correctly set button's class in interfacebuilder. has predefined value set, nsbutton. have set mcbutton instead.

only reference correct instance of 1 of mcbuttons.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -