How to require that a protocol can only be adopted by a specific class

后端 未结 4 1623
灰色年华
灰色年华 2021-02-01 00:13

I want this protocol:

protocol AddsMoreCommands {
     /* ... */
}

only to be adopted by classes that inherit from the class UIViewContro

4条回答
  •  南方客
    南方客 (楼主)
    2021-02-01 00:28

    Now in Swift 5 you can achieve this by:

    protocol AddsMoreCommands: UIViewController {
         /* ... */
    }
    

    Quite handy.

提交回复
热议问题