Tuesday, 6 August 2013

Convert Objective-C enum constants to string names

Convert Objective-C enum constants to string names

Previously, this was impossible (you have to write it all out by hand /
create a static array / put all the values into a dictionary and read them
back ... etc)
But I've noticed that the latest Xcode's lldb (4.6, maybe earlier versions
too) is automatically converting enum-constants to strings.
My problem is that we use a lot of libraries - including Apple's own! -
which use annoying public enums with no "value-to-string" method offered.
So I end up having to (many, many times over) do the "well, since Mr.
Library Author didn't do this, now I have to make the static array for
them...".
I kept hoping Apple would provide a way out of this - is it finally here?
Or is this some trick that only the debugger can do - mere runtime code
has no access to it?

No comments:

Post a Comment