ios - How do I turn the text of a button to a variable in Swift? -
how turn text of button variable in swift? can come far, isn't working:
var answer = "example" @ibaction func button1(sender: anyobject) { var answer = button1.text } any appreciated. thanks!
to title of uibutton have reach child uilabel:
@ibaction func button1(sender: anyobject) { let button = sender uibutton // as! swift 1.2 var answer = button.titlelabel!.text }
Comments
Post a Comment