ios - 参数标签 "(attributes:)"与 DispatchQueue 中的任何可用重载都不匹配

标签 ios swift xcode sprite-kit

我正在尝试使用 DispatchQueue 让游戏中的敌人移动。我尝试修复此错误,但它一直告诉我属性不匹配任何可用的重载。

 func makeAIMove() {
    let strategistTime = CFAbsoluteTimeGetCurrent()

    DispatchQueue.global(attributes: .qosUserInitiated).async { [unowned self] in

        guard let move = self.strategist.bestMoveForActivePlayer() as? Move else { return }

        let delta = CFAbsoluteTimeGetCurrent() - strategistTime

        DispatchQueue.main.async{ [unowned self] in

            self.rows[move.row][move.col].setPlayer(.choose)

            let aiTimeCeiling = 2.0

            let delay = min(aiTimeCeiling - delta, aiTimeCeiling)

            DispatchQueue.main.after(when: .now() + delay) { [unowned self] in

                self.makeMove(row: move.row, col: move.col)

            }
        }
    }

}

最佳答案

我想你想要的是 DispatchQueue.global(qos: .userInitiated);实际上,没有采用 attributes 参数的重载。

关于ios - 参数标签 "(attributes:)"与 DispatchQueue 中的任何可用重载都不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43922563/

相关文章:

ios - 我如何停止这个 NSThread?

ios - Swift 3 获取通知数据

ios - 保留发送到释放的 UIViewController

ios - 检查 CLLocation 是基于 GPS 还是基于蜂窝

swift - 创建加载图像/事件指示器,直到图像快速显示在屏幕上

ios - 如何将 AdBannerView 添加到 UITabViewController?

ios - 如何构建 libwebsocket 库(Socket 编程)并集成到 iOS 应用程序中

ios - 从图像中获取子图像

ios - 组件的尾部约束等于其前导约束

ios - Xcode Convert to ARC, Create universal binary fails with error of "can' t 找出架构类型”