如何以编程方式检索协议名称?
protocol SomeProtocol {
func printName()
}
extension SomeProtocol {
func printName() {
print("Name?")
}
}
答案 0 :(得分:1)
print(SomeProtocol.self)
或者如果您想要String
let name = String(describing: SomeProtocol.self)
print(name)