enum打印 CustomStringConvertible
2018-12-12 10:37 法子 阅读(409) 评论(0) 编辑 收藏 举报
CustomStringConvertible协议可以用来打印自定义的类和结构体
enum DownUpPhase: CustomStringConvertible { case MovingDown, MovingUp var description: String { get { switch self { case .MovingDown: return "Moving Down" case .MovingUp: return "Moving Up" } } } } var phase: DownUpPhase = .MovingDown print(phase) //输出:Moving Down