I have a generic class of type T and I would like to get the name of the type that passed into the class when instantiated. Here is an example.
class MyClas
Another possible solution that might help somebody:
Playground
import Foundation
class ClassType {
static func name () -> String
{
return "\(T.self)".componentsSeparatedByString(".").last!
}
}
class MyClass {
}
func testClassName(){
let className = ClassType.name()
print(className)
}
testClassName()