Reputation: 27211
How can I retrieve the name of a protocol programmatically?
protocol SomeProtocol {
func printName()
}
extension SomeProtocol {
func printName() {
print("Name?")
}
}
Upvotes: 0
Views: 48
Reputation: 13354
print(SomeProtocol.self)
Or if you want as String
let name = String(describing: SomeProtocol.self)
print(name)
Upvotes: 1