Xcode Version 6.0 (6A279r): [Swift] String representation of enum cases
| Originator: | janoschhildebrand | ||
| Number: | rdar://17662357 | Date Originated: | 14-Jul-2014 |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode 6.0 (6A279r) |
| Classification: | Feature Request | Reproducible: | NA |
Summary:
A nice to have feature would be to get a string representation of an enum case, i.e. to ask it for its name.
Since each enum case already needs to have a unique name/descriptor, it should be possible to simple return that at runtime.
For example, given the following enum:
enum Foo {
case Bar
}
let foo = Foo.Bar
let name = foo.caseName // "Bar"
No associated values or information about those would be included with the name.
This would allow conversion of all enum cases to a primitive representation without resorting to raw values or manually providing names for all cases. This can be useful for generating descriptions of enums, serialization, etc...
Obviously this also can/will be part of the reflection APIs provided for enum types in some way so it might not make much sense to include it separately.
Steps to Reproduce:
Expected Results:
Actual Results:
Version:
Xcode 6 - Beta 3 (6A254o)
Swift version 1.0 (swift-600.0.38.7)
OS X 10.10 (14A283o)
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!