Get an Int out of an UILabel Swift
问题 I have the problem, to have a high amount of buttons which have a number as their label, so i thought i could take the label as an integer instead of creating an action for every button?! @IBAction func NumberInput(sender: UIButton) { var input:Int = sender.titleLabel as Int } 回答1: If you want to do this, you can convert the string to an Int by using string.toInt() such as: if let input = sender.titleLabel?.text?.toInt() { // do something with input } else { // The label couldn't be parsed