0
我读了关于这个错误的信息,我知道它在编译器不知道它需要返回什么类型时发出警报,但是这个错误并没有出现,并且我不知道它为什么出现在今天。模糊使用下标错误
这是我的代码:
func animateCounter(from: Int, to: Int) {
timer = NSTimer.scheduledTimerWithTimeInterval(duration, target: self, selector: "increaseCounter", userInfo: ["from": from, "to": to], repeats: false)
}
func increaseCounter() {
let from = timer.userInfo!["from"] as! Int
let to = timer.userInfo!["to"] as! Int
}
我把我的from
和to
变量均为整数,那么,为什么我得到这个错误?
你必须能够之前投了'userInfo'到词典通过下标访问其内容。 – luk2302
这很有趣,但它现在起作用。我没有做任何改变= / –