0
Ben protokol ve bunun gibi uzantıyı"A" ifadesini "A protokolüne uygun" olarak nasıl yapabilirim?
protocol FooProtocol: class {
}
extension FooProtocol where Self: UIView {
func changeAlphaToZero() {
self.alpha = 0
}
}
ilan etti ve böyle changeAlphaToZero()
, kullanmaya çalıştı (sadece bir örnek.)
class MyClass {
func setViewAlphaToZeroIfNeeded(view: UIView) {
if let v = view as? FooProtocol {
v.changeAlphaToZero() // Compile Error "FooProtocol is not a subtype of UIView."
}
}
}
Can Ben view
"UIView FooProtocol uygundur etmek döküm "?