Swift - Associated value or extension for an Enum
问题 General question regarding swift enum. I want to create an enum of "icon" and "associate" a value to the enum case enum Icon { case plane case arrow case logo case flag } I want to create an associated image to the enum's value. And also an associated color to the enum value So for instance if it was possible to do something like: extension Icon.plane { var image = { get { return UIImage("plane.png") } } var color = { get { return UIColor.greenColor() } } } var image = Icon.arrow.image // the