【发布时间】:2018-10-14 12:33:12
【问题描述】:
有没有办法从超类访问子类方法? switch 语句位于超类的函数中。 createCityOne()、createCityTwo() 和 createCityThree() 等函数都在它们自己的子类中。
if transitionSprite.name == nil || transitionSprite.name == "rd-d2c" || transitionSprite.name == "rd-f2c" || transitionSprite.name == "rd-c2c" {
print("city should come next")
switch randomIndex {
case 0:
cityOne.createCityOne()
print("1")
case 1:
cityTwo.createCityTwo()
print("2")
case 2:
print("3")
cityThree.createCityThree()
default:
break
}
【问题讨论】:
标签: swift inheritance subclass superclass