0
votes

I have declared some enum values in view controller and trying to access in another class, but for some enum I can infer directly but for other I need to use the class name. Sample code

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
   }
  }

Here in the second function of Utitlity if I declare like func showAnimation(_ animation: Animation) it throws error "Use of undeclared identifier Animation"

Why did in first method worked even though I didn't mention class but in the second one didn't?

2
It should not work in any case, I think you have some another class for Configurations, can you pls check and confirm? - Sohil R. Memon

2 Answers

0
votes

FYI: addConfiguration is giving error.

Error

Please check in your source code, I am sure any framework is having Configurations class or enum is defined in your project.

That's it

0
votes

enter image description here

please check your first function is not work.

it throws error "Use of undeclared identifier Animation"

so you have change your source code first. thanks..