Skip to content

Instantly share code, notes, and snippets.

@edc0der
Created April 10, 2018 00:56
Show Gist options
  • Save edc0der/51e0a565aeddf15ea80c8e9d0585ada0 to your computer and use it in GitHub Desktop.
Save edc0der/51e0a565aeddf15ea80c8e9d0585ada0 to your computer and use it in GitHub Desktop.
Get class name without namespace in Swift
func className(target: AnyObject) -> String {
let nameSpaceClassName = NSStringFromClass(type(of: target))
if let className = nameSpaceClassName.components(separatedBy: ".").last {
return className
}
return ""
}
@edc0der
Copy link
Author

edc0der commented Apr 10, 2018

Retrieves class name without namespace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment