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
這很有趣,但它現在起作用。我沒有做任何改變= / –