Swift generic variable

前端 未结 2 510
灰色年华
灰色年华 2021-01-15 20:17

I have a protocol, and I\'d like to have a variable of type UIViewController implementing mu protocol. If I try to do something like:

var delegate:UIViewCon         


        
2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-15 20:45

    If the class implements a protocol you don't care about which class it actually is. This should work:

    var delegate: BouncingMenuDelegate?
    

提交回复
热议问题