【发布时间】:2019-12-16 09:53:52
【问题描述】:
我已经在视图控制器中声明了一些枚举值并尝试在另一个类中访问,但是对于某些枚举我可以直接推断,但对于其他我需要使用类名。示例代码
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
}
}
如果我在 Utitlity 的第二个函数中声明 func showAnimation(_ animation: Animation) 它会抛出错误“使用未声明的标识符动画”
为什么在第一种方法中我没有提到类但在第二种方法中没有?
【问题讨论】:
-
无论如何都不行,我想你还有
Configurations的课,你能检查确认一下吗?
标签: ios xcode enums xcode10 swift4.2