'Passing All type of enum to a UIPicker ViewController

i wanted to built an picker ViewController, this vc requires an enum data that's inherit the CaseIterable protocol.

Tried looking for it here Swift - Passing different enum types for same variable to a class

still does not answer my problem.

Are there a way to somehow do something like that? Thanks

here are what I have done so far

class PickerDisplayViewController: UIViewController {
    let picker: UIPickerView = {
        let picker = UIPickerView()
        return picker
    }()
    
    // any enum that that inherit the CaseIterable protocol
    var data: PickerEnumType? <-- ERROR

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

}
protocol PickerEnumType: CaseIterable {
    
}

p.s : you cant use generic classes (it shows errors, but that's another question)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source