【发布时间】:2017-02-10 01:22:32
【问题描述】:
我正在使用 swift 制作一个模拟远程控制 Iphone 应用程序,而 Xcode 不允许我在 UILabel 的文本上使用 .toInt()。我正在尝试将文本从标签转换为整数,但我不知道该怎么做。有人可以帮帮我吗?谢谢。
这是我的代码:
@IBAction func channelInc(_ sender: UIButton) {
var chnl = channel.text!.toInt()
if (chnl!+1 > 99) {
} else {
let newChnl = chnl!+1
channel.text = "\(String(newChnl))"
}
}
【问题讨论】:
标签: swift