In Swift, we can no longer use "self.class".
I want to print own class name for description method in subclass of NSObject.
How can I print it? Or I should make new method for getting class name?
I checked the following question, but I couldn't get the answer.
How do I print the type or class of a variable in Swift?
How do you find out the type of an object (in Swift)?
import UIKit
class PrintClassName: NSObject {
override init() {
super.init()
println("\(self.dynamicType)")
// Prints "(Metatype)"
println("\(object_getClassName(self))");
// Prints "0x7b680910 (Pointer)"
println("\(self.className)")
// Compile error!
println(PrintClassName.self)
// Prints "(Metatype)"
}
}
2014.08.25 postscript
I checked the question.
Swift class introspection & generics
But println(PrintClassName.self)
prints "(Metatype)"
And I want to get class name without writing the class name on source code.