Enums group together a related set of possible values. For things like app status, screen routes, payment state, direction, and theme mode, writing them as an enum is much safer than typing out random strings.
swift
enum AppTheme {
case light
case dark
case system
}
let selectedTheme = AppTheme.dark
switch selectedTheme {
case .light:
print("Use light colors")
case .dark:
print("Use dark colors")
case .system:
print("Follow device setting")
}AppTheme enum defines three possible app theme options. switch handles every enum case, which cuts down on future bugs.
You should see
Use dark colors