I have a named enumeration
enum{
MyErrorCodeOne = 1
MyErrorCodeTwo = 2
}MyErrorCodes;
Is there a way when I encounter 2 for instance that I NSLog “MyErroCodeOne” to the user as opposed to 2. A switch statement is not the case because I have about 50 error codes at the moment. Any help would be appreciated.
The comment response is good, but you could also just have an array defined globally, say error names like so:
NSArray *errorNames = [NSArray arrayWithObjects:@”MyErrorCodeOne”, @”MyErrorCodeTwo”, nil];
and reference it by [errorNames objectAtIndex:MyErrorCodeOne];
Only if that’s easier for you. The first response would be the best, in my opinion.