save enum value in userdefaults swift code example
Example 1: swift userdefaults enum
UserDefaults.standard.set(switchCurrentType.rawValue, forKey: "CurrentDefaultType")
Example 2: swift userdefaults enum
//in the didMoveToView method put this code in
switchCurrentType = ExampleEnum(rawValue: UserDefaults.standard.integer(forKey: "CurrentDefaultType"))! //make sure exclamation mark at the end is there or it won't read properly