Member-only story

How to convert enum case to the string type?

Fredric Cliver
Oct 20, 2020

--

Sometime, you might need the enum’s case name as a string, but the rawValue.

In that case, you need the class

“String(describing:)”

Use this.

String(describing: YOURENUM.YOURCASE)
and then ‘YOURCASE’ will be printed.

--

--

Fredric Cliver
Fredric Cliver

Written by Fredric Cliver

Physics graduate with 13 years of diverse experience in the IT industry. Founded and managed a startup for 3 years.

No responses yet