Ios Swift 4中[MoveCommand]的替代品是什么
我正在学习iOS开发,并在YouTube上观看了一个从2014年开始就非常古老的教程Ios Swift 4中[MoveCommand]的替代品是什么,ios,swift4,Ios,Swift4,我正在学习iOS开发,并在YouTube上观看了一个从2014年开始就非常古老的教程 import UIKit protocol GameModelProtocol: class { func scoreChange(score: Int) func moveOneTile(from: (Int, Int), to: (Int, Int), value: Int) func moveTwoTile(from: ((Int, Int), (Int, Int)), to:
import UIKit
protocol GameModelProtocol: class {
func scoreChange(score: Int)
func moveOneTile(from: (Int, Int), to: (Int, Int), value: Int)
func moveTwoTile(from: ((Int, Int), (Int, Int)), to: (Int, Int), value: Int)
func insertTile(location: (Int, Int), value: Int)
}
[![enter image description here][1]][1]
class GameModel: NSObject {
let dim: Int
let limit: Int
var score: Int = 0 {
didSet {
delegate.scoreChange(score: score)
}
}
var gameBoard: SquareGameBoard<TileObject>
let delegate: GameModelProtocol
var queue: [MoveCommand]
var timer: Timer
let maxCommands = 100
let queueDelay = 0.3
init(dim d: Int, limit l: Int, delegate: GameModelProtocol) {
dim = d
limit = l
self.delegate = delegate
queue = [MoveCommand]()
timer = Timer()
gameBoard = SquareGameBoard(dim: d, initialValue: .Empty)
super.init()
}
教练说他把它当作一个阵列。但我不知道它是如何被使用的,也不知道如何将其更改为与Swift 4一起使用
以下是YouTube视频的链接
我只是想知道如何替换[MoveCommand]以在Swift 4中工作。我已经修复了代码中的大部分问题,但这个问题我无法解决
MoveCommand是在AuxiliaryModels.swift中定义的结构。您应该下载完整的项目示例代码: 希望这有帮助