Get an Int out of an UILabel Swift

后端 未结 6 1836
执笔经年
执笔经年 2021-01-20 17:22

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

6条回答
  •  暖寄归人
    2021-01-20 17:59

    You should make sure that the text exists

    var input:Int = (sender.titleLabel.text! as NSString).integerValue
    

提交回复
热议问题