swift - UIButton action generates a SIGABRT but no breakpoint triggers -


i have code create button on storyboard

override func viewdidload() {     super.viewdidload()     ...     signupbutton.addtarget(self, action: "pressed:", forcontrolevents: .touchupinside)     ...  }  func pressed(sender:uibutton!) {      println("pressed") }        

however, throws sigabrt error when press button. so, added breakpoint on exceptions. however, no breakpoint ever - threw exception. how find out what's causing error?

you have 2 issues here...

first: placed pressed function in scope of viewdidload, when needs outside of function , in scope of class. move function pressed out of viewdidload().

second: not causein signal abort crash, needed nonetheless. add semicolon action selector name.

signupbutton.addtarget(self, action: "pressed:", forcontrolevents: .touchupinside) 

or, if don't need pass object function pressed, change function header func pressed().

basic example: (tested , working in new project)

class viewcontroller: uiviewcontroller {      override func viewdidload() {         super.viewdidload()          let signupbutton = uibutton(frame: cgrectmake(0, 0, 100.0, 100.0))         signupbutton.settitle("button", forstate: uicontrolstate.normal)         signupbutton.addtarget(self, action: "pressed:", forcontrolevents: .touchupinside)         self.view.addsubview(signupbutton)     }      func pressed(sender:uibutton!) {         println("button pressed")     } } 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -