It’s small wonder that there is no standard way to get enum string description.
This is a code snippet solves the problems the easiest way:
// In a header filetypedef enum { JSON, XML, Atom, RSS} FormatType;
NSString * const FormatType_toString[];
// In a source fileNSString * const FormatType_toString[] =
{ @"JSON", @"XML", @"Atom", @"RSS"};...// To convert enum
to string:NSString *str = FormatType_toString[theEnumValue];
If you change the enum don’t forget to change the array of descriptions.
Second way is to create a mapping table. It’s more expensive in both sense
(your brain time and processor time) so i prefer the first one.