So, I\'ve got this definition:
typedef enum {
red = 1,
blue = 2,
white = 3
} car_colors;
Then, I\'ve got a variable of type car_col
Rather than use an array, why not use a dictionary; You have the colour NSString as keys, and you return whatever NSNumber you want. Something like; (Long winded for clarity).
NSDictionary *carColourDictionary = @{@"Red": @1,
@"Blue": @2,
@"White": @3};
// Use the dictionary to get the number
// Assume you have a method that returns the car colour as a string:
// - (NSString *)colourAsString;
int carColour = carColourDictionary[object colourAsString];