I have a generic method in one of my classes where I want to have a generic type conforming to UIViewController
and UIPickerViewDelegate
. How can I do that? I thought of doing this:
func foo<T: UIViewController, UIPickerViewDelegate> (#viewController: T) {}
But this code doesn't "recognize" the UIPickerViewDelegate
. I also thought of using the pipe |
instead of the comma but this is even worse, the compiler doesn't accept that.
Is it possible to do this or do I have to do 2 parameters for the class and the protocol? Or is there a nicer workaround?
Thanks for your help and Merry Christmas :]