> How do I use the variable to describe the case?
> I've tried
> but, of course, that didn't work.
> There must be some way to convert variables "fill in" elements in the dotted syntax elements.
> Anybody know?
There’s no built-in way to look up an enum case by name; that sort of behavior is usually reserved for much more dynamic languages than Swift.
You do have a couple options to get it for a specific enum, however. One is to build a dictionary mapping the names to the cases:
At some point I get user input or some other means to assign a variable which will contain the TEXT of the instance name.
How do I substitute the instance name by that variable?
You build your own dictionary that maps names to enum values. As has already been said, Swift does not support this type of introspection.
(Even if the language let you do this, it would probably be a bad idea to expose the internal enum names in your program’s user interface. For one thing, it’s not localizable. For another, Swift identifiers don’t allow niceties like whitespace, so you’d have to show dorky names like “TenOfSpades” or “speed_up” in your UI :-p )
If it can't be done, it can't be done but it seems like something I've been able to do in other languages.
Scripting languages tend to support that type of stuff, since they’re very dynamic. It’s not something you’ll find in C or C++, though.