Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • They changed it in Swift 3.0. Now you can get string from type(of: self) Commented Mar 10, 2017 at 12:43
  • Updated to Swift 3. Commented Mar 11, 2017 at 9:19
  • I think this is the best way to get type name: any instance of class, based on NSObject, enum, typealiase, functions, var properties, and any types, even constants. For types, you have to use .self. For example, typeName(Int.self), typeName(true.self). Nor you need to worry about project name as part(such as AppProj.[typename]) Great! Commented Oct 16, 2018 at 17:53