【发布时间】:2016-01-28 16:29:05
【问题描述】:
我刚刚升级到 Swift 2.0,不确定为什么这行代码不起作用。我知道 toInt() 已在 Swift 2.0 中删除,但我不知道如何更新这行代码,所以它会在 Swift 2.0 中工作。有什么建议吗?
旧行:
followers.setTitle((followers.currentTitle!.toInt()! - 1).description, forState: UIControlState.Normal)
我试过这条线没有成功:
followers.setTitle((followers.currentTitle!.Int()! + 1).description, forState: UIControlState.Normal)
【问题讨论】:
-
声明一个
Int变量让追随者计数器进行数学运算并使用String(counter)更新标题可能更有效。