How to get the name of enumeration value in Swift?
问题 If I have an enumeration with raw Integer values: enum City: Int { case Melbourne = 1, Chelyabinsk, Bursa } let city = City.Melbourne How can I convert a city value to a string Melbourne ? Is this kind of a type name introspection available in the language? Something like (this code will not work): println("Your city is \(city.magicFunction)") > Your city is Melbourne 回答1: As of Xcode 7 beta 5 (Swift version 2) you can now print type names and enum cases by default using print(_:) , or