I have an enum holding several values:
enum {value1, value2, value3} myValue;
In a certain point in my app, I wish to check which value of
This is answered here: a few suggestions on implementation
The bottom line is Objective-C is using a regular, old C enum, which is just a glorified set of integers.
Given an enum like this:
typedef enum { a, b, c } FirstThreeAlpha;
Your method would look like this:
- (NSString*) convertToString:(FirstThreeAlpha) whichAlpha {
NSString *result = nil;
switch(whichAlpha) {
case a:
result = @"a";
break;
case b:
result = @"b";
break;
case c:
result = @"c";
break;
default:
result = @"unknown";
}
return result;
}