Obligado a emitir, incluso si el protocolo requiere un tipo dado
Tengo el siguiente código:
import UIKit
protocol Fooable: class where Self: UIViewController {
func foo()
}
class SampleViewController: UIViewController, Fooable {
func foo() {
print("foo")
}
}
let vc1: Fooable = SampleViewController()
let vc2: Fooable = SampleViewController()
// vc1.show(vc2, sender: nil) - error: Value of type 'Fooable' has no member 'show'
// (vc1 as! UIViewController).show(vc2, sender: nil) - error: Cannot convert value of type 'Fooable' to expected argument type 'UIViewController'
(vc1 as! UIViewController).show((vc2 as! UIViewController), sender: nil)
las líneas comentadas no se compilan.
Por qué ¿Estoy obligado a emitir objeto de tipo de protocolo aUIViewController
incluso siFooable
protocolo requiere, que los tipos que se ajustan a él heredan deUIViewController
?