Swift 2 - switch 语句给我错误
Swift 2 - switch statement giving me errors
我不知道哪里出了问题,但是下面的代码在 switch 语句中给了我很多错误:
enum GameState {
case Start
case Tutorial
case Play
case ShowingScore
case GameOver
}
在 class 游戏场景中:
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
switch GameState {
case .Start: break
case .Tutorial: break
case .Play:
beginningTouchPosition = location
tappedForBird = true
break
case .ShowingScore: break
case .GameOver: break
}
}
}
我收到的错误信息是:
- 类型名称后预期的成员名称或构造函数调用(这在 switch GameState 行中)
- 在类型 "GameState" 中未找到枚举案例 "Start"(我不仅为 .Start,而且为每个 GameState 案例都找到了这个案例)
您正在打开枚举类型 GameState
。
您应该打开一个包含 GameState
情况之一的变量
我不知道哪里出了问题,但是下面的代码在 switch 语句中给了我很多错误:
enum GameState {
case Start
case Tutorial
case Play
case ShowingScore
case GameOver
}
在 class 游戏场景中:
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
switch GameState {
case .Start: break
case .Tutorial: break
case .Play:
beginningTouchPosition = location
tappedForBird = true
break
case .ShowingScore: break
case .GameOver: break
}
}
}
我收到的错误信息是:
- 类型名称后预期的成员名称或构造函数调用(这在 switch GameState 行中)
- 在类型 "GameState" 中未找到枚举案例 "Start"(我不仅为 .Start,而且为每个 GameState 案例都找到了这个案例)
您正在打开枚举类型 GameState
。
您应该打开一个包含 GameState