ios - 什么可以替代 Swift 4 中的 [MoveCommand]
问题描述
我正在学习 iOS 开发,并且正在观看 2014 年以来非常古老的 YouTube 教程。
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 中定义的结构。您应该下载完整的项目示例代码:https
://github.com/austingzheng/swift-2048
希望这会有所帮助。
推荐阅读
- javascript - Cordova App 创建目录
- model - 为什么我的模型对象在 dotnet core 2.x Razor 页面应用程序中的 Razor 页面上始终为空?
- mysql - 已将握手入队后无法将握手入队。使用 http 客户端和服务器获取数据
- javascript - D3.js 树 - 文本没有出现在节点内部、Firefox 或边缘
- windows - 在另一个命令行中将批处理命令行设置为字符串
- php - 检查数组中的前 5 个和后 5 个索引
- python - 不存在具有给定属性的相关模型时的 SQLAlchemy 查询模型
- ruby-on-rails - Rubymine 找不到 gem docker rvm
- python - 选择列表中每个子列表的前两个元素
- python - 根据df中的另一列值选择df pandas中的元素