Is there a way to dump the rawValue enum to its type?
2 answers
Given your code, I assume you have an enum nested inside a class like this:
class MyClass {
enum Difficulty: Int {
case Opt1 = 1, Opt2 = 2, Opt3 = 3
}
}
var myInteger = MyClass.Difficulty.Opt2.rawValue // Int inferred correctly
I don't find any problem with this or any options I can think of. Please write your code for the MyClass type if you are still facing problems.
+2
source to share