gpt4 book ai didi

swift 错误 : Int is not convertible to 'DictionaryIndex'

转载 作者:可可西里 更新时间:2023-11-01 01:44:00 26 4
gpt4 key购买 nike

当我从 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

关于 swift 错误 : Int is not convertible to 'DictionaryIndex<Int,Int>' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25169457/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com