: Playground-noun:a place where people can playimport uikitenum month:int{ //So defined, after the Feb, Mar will automatically be assigned a value of 2 and 3 . Case Jan = 1, Feb, Mar, APR, May, June, July, Dec}let, Sep, Oct, Nov, Currentmonth:month =. nov//View the value of the enumeration currentmonth.rawvalue//the enumeration variable created by this method is a selectable variable. After unpacking, use let Nextmonth = Month (rawvalue:12) nextmonth!. rawvalue//example var userinputnumber = 0if Let Themonth = Month (rawvalue:userinputnumber) { switch themonth {case . J An: print ("It's the first month") Case . DEC: print ("It's the last month") default: print ("It's the normal month")} } else { print ("ERROR" The default values associated with}//Swift are not just integers, but other types of enums such as strings, personnum:string{case One = "RINPE" Case--" Lili" Case thre E = "Lolo"}//example let Userinput = "Rinpe" if Personnum (rawvalue:userinput)! = Nil { print ("Welcome, \ (Userinput) professor")} else { print ("Sorry, you are not an employee of the Company")}
Swift-39-Enum type association default