我在视图控制器中声明了一些枚举值,并试图在另一个类中进行访问,但是对于某些枚举,我可以直接推断,但对于另一些情况,我需要使用类名。样本代码
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),它会抛出错误“使用未声明的标识符动画”。
为什么在第一种方法中,即使我没有提到课程,但在第二种方法中,却不起作用?
发布于 2019-12-16 10:32:05
FYI: addConfiguration出错了。

请签入您的source code,我相信任何framework都会在您的项目中定义Configurations class或enum。
就这样
https://stackoverflow.com/questions/59354162
复制相似问题