//: Playground - noun: a place where people can playimport UIKitenum Month: Int{ // 这么定义, 后面的Feb, Mar会自动赋值为2和3.. case Jan = 1, Feb, Mar, Apr, May, Jun, July, Aug, Sep, Oct, Nov, Dec}let currentMonth:Month = .Nov// 查看枚举对应的值currentMonth.rawValue// 通过这种方法创建出来的枚举变量是一个可选型变量..需要解包后使用let nextMonth = Month(rawValue: 12)nextMonth!.rawValue// 示例var userInputNumber = 0if let theMonth = Month(rawValue: userInputNumber) { switch theMonth { case .Jan: print("It's the first month") case .Dec: print("It's the last month") default: print("It's the normal month") }} else { print("ERROR")}// swift中关联的默认值不仅仅是整数, 也可以字符串等其他类型enum PersonNum: String{ case one = "Rinpe" case two = "Lili" case three = "Lolo"}// 示例let userInput = "Rinpe"if PersonNum(rawValue: userInput) != nil { print("欢迎您, \(userInput)教授")} else { print("对不起, 您不是本公司的员工")}