我有以下协议:
protocol ViewCreator {
associatedtype ResultView: View
@ViewBuilder func createView() -> ResultView
}
我想获取它的类型,例如获取它的名称。所以我写了以下代码:
let typeName = String(describing: ViewCreator.self)
但是遇到了以下错误:
协议“ViewCreator”只能用作泛型约束,因为它具有Self或关联类型的要求。
在这种情况下,我应该如何获取带有关联类型的协议的“self”?
P.S. 我没有这个协议的实现在范围内。