Andrew Andrew - 1 year ago 111
Swift Question

is there exist some alternative of Enum.GetName(Type, Object) method in Swift?

in c# is possible to get enum name of any type with method

Enum.GetName (Type, Object)

is there possible to do the same in Swift?

As example I have some enum that must have Int raw value, but also I need it's own name.
how to do this in Swift 3?

Answer Source

To get an enumeration case's name as a String, you can use init(describing:) on String:

let s = String(describing: Foo.A) // "A"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download