So here is my playground, i would love to use the openInitial111() function but it just wont compile, the openInitial222() is working perfectly, whats the problem ?
protocol Module : Screen {
init()
}
extension Module {
static func entity() -> Self {
return Self()
}
}
protocol Screen {
}
class FFF: Module {
required init() {
}
}
class ZZZ: NSObject {
func openInitial111(initialModule: Module.Type) {
self.openViewController(itemWithScreenStyle: initialModule.entity()) // Error : Cannot invoke openViewController
//with an argument list of type '(initWithScreenStyle:Module)
}
func openInitial222(initialModule: Module.Type) {
let f = FFF.self // FFF.Type
self.openViewController(itemWithScreenStyle: f.entity()) // works
}
func openViewController<T: Screen>(itemWithScreenStyle: T) {
print("generics")
}
}