I have got this code:
protocol GenericProtocol: class {
associatedtype type
func funca(component: type)
}
class MyType {
weak var delegate
This is not possible to use generic protocols. Use concrete type or usual protocol instead. You have to declare concrete T outside of those abstractions
For instance, this should work:
class MyType {
weak var delegate: UsingGenericProtocol? // First error
var t: T
init(t: T) {
self.t = t
}
func finished() {
delegate?.funca(component: t) // Second error
}
}
class UsingGenericProtocol: GenericProtocol {
let myType: MyType
typealias type = T
init(t: T) {
myType = MyType(t: t)
}
func funca(component: T) {
}
}
let instance = UsingGenericProtocol(t: 0)