Skip to content

Instantly share code, notes, and snippets.

@SergLam
Forked from edc0der/Generics+Utilities.swift
Created November 9, 2023 09:13
Show Gist options
  • Save SergLam/c614dd30d9abb02cd65447cc9905e38c to your computer and use it in GitHub Desktop.
Save SergLam/c614dd30d9abb02cd65447cc9905e38c 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 ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment