当我从 Xcode 6 beta 4 切换到 beta 5 时,我在引用我的 plays
变量时收到此错误(Int 无法转换为“DictionaryIndex”)。我不知道如何解决这个问题。
这是代码块:
var plays = Dictionary<Int,Int>()
var done = false
var aiDeciding = false
//Function that says what to do if a UIButton is clicked:
@IBAction func UIbuttonClicked(sender:UIButton) {
if !plays[sender.tag] && !aiDeciding && !done {
setImgforCircle(sender.tag, player:1)
thinkingLabel.hidden = true
thinkingLabel2.hidden = true
thinkingLabel3.hidden = true
}
最佳答案
我认为这只是一个欺骗性的错误消息,实际的错误在
if !plays[sender.tag]
相反,它应该是
if plays[sender.tag] != nil
关于快速错误: Int is not convertible to 'DictionaryIndex<Int,Int>' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25169457/