我已经在视图控制器中声明了一些枚举值,并试图在另一个类中进行访问,但是对于某些枚举,我可以直接进行推断,而对于其他枚举,我需要使用类名。示例代码
class MyRootViewController: UIViewController {
enum Animation {
case left
case right
case top
case bottom
case none
}
//some code
}
class OtherViewController: UIViewController {
enum Configurations {
case config
case version
case type
}
//some code
}
class Utility {
func addConfiguration(_ config: Configurations) {
//some code
}
func showAnimation(_ animation: MyRootViewController.Animation) {
//Some code
}
}
如果我像func showAnimation(_ animation: Animation)
那样声明,它在Utitlity的第二个功能中会引发错误“使用未声明的标识符动画”
即使我没有提到课堂,但在第二种方法却没有,为什么在第一种方法中起作用?