Get an Int out of an UILabel Swift

后端 未结 6 1833
执笔经年
执笔经年 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 18:16

    You can't convert a UILabel to an Int. I think you want this instead:

    var input : Int? = sender.titleLabel.text?.toInt()
    

提交回复
热议问题