无法将string类型的值转换为期望的参数类型Int

时间:2017-04-16 02:13:55

标签: json swift

我正在玩代码。我在GitHub(https://github.com/avijeets/ConnectFour)上找到了,并且在我无法清除的错误中彻底难倒。

错误是:

  

“无法将'[[CFCellState]]'类型的值转换为预期的参数   输入'Int'“

定义CFCellState的VC顶部的代码:

enum CFCellState: CustomStringConvertible {
    case empty
    case occupied(CFPlayer)

    var description: String {
        switch self {
        case .empty:
            return "empty"
        case .occupied(let player):
            return player.description
        }
    }
}

发生错误的代码:

self.init(player: current!, opponent: opponent!, columns:ConnectFour.boardFrom(json: queryItems[1].value!)!)

1 个答案:

答案 0 :(得分:0)

请改为尝试:

self.init(player: current!, opponent: opponent!, board: ConnectFour.boardFrom(json: queryItems[1].value!)!)

为了实现这一点,您可能需要在private文件中删除 {@ 1}}关键字(查看#98行):

ConnectFour.swift