Created
April 10, 2018 00:56
-
-
Save edc0der/51e0a565aeddf15ea80c8e9d0585ada0 to your computer and use it in GitHub Desktop.
Get class name without namespace in Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func className(target: AnyObject) -> String { | |
let nameSpaceClassName = NSStringFromClass(type(of: target)) | |
if let className = nameSpaceClassName.components(separatedBy: ".").last { | |
return className | |
} | |
return "" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Retrieves class name without namespace.