Skip to content

Instantly share code, notes, and snippets.

@simonbromberg
Created January 1, 2017 04:54
Show Gist options
  • Save simonbromberg/b01e61e06f92c8290188dc2cf7b4a528 to your computer and use it in GitHub Desktop.
Save simonbromberg/b01e61e06f92c8290188dc2cf7b4a528 to your computer and use it in GitHub Desktop.
Extension for getting string of class name in Swift (could extend any type of class really, perhaps even AnyObject); replacement for NSStringFromClass() in Objective C
import Foundation
extension NSObject {
var className: String {
return String(describing: type(of: self))
}
class var className: String {
return String(describing: self)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment