我要这个协议:
protocol AddsMoreCommands { /* ... */ }
只能由继承自类UIViewController的类采用。此页告诉我,我只能通过编写类(而不是结构)来指定它。
UIViewController
protocol AddsMoreCommands: class { }
但是,我看不出如何要求它只为某一阶层所采用。那一页以后讨论了在协议扩展中添加where子句以检查一致性,但我也看不出如何调整它。
where
extension AddsMoreCommands where /* what */ { }
有办法这样做吗?谢谢!
发布于 2016-02-01 15:55:51
protocol AddsMoreCommands: class { // Code } extension AddsMoreCommands where Self: UIViewController { // Code }
https://stackoverflow.com/questions/35133887
相似问题