Jonny Jonny - 1 month ago 8
Swift Question

Enum with .default Option

This question is basically to study, there is no "why?" or "instead of ..."

In Swift 3 it is very common to use the .default, exemplifying:



UIApplication.shared.statusBarStyle = .default
// from UIStatusBarStyle.default



And I was thinking, how?
In my tests I did not succeed, I try something like:



class Test {
enum Options {
case light, default // bad world
}
}



Thank you :)

Answer

Do like this:

class Test {
  enum Options:Int {
    case `default`
    case lightContent

  }
}