-
-
Save SergLam/c614dd30d9abb02cd65447cc9905e38c 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