I read a NSString from file and then I want to #define this as a UIColor so I can quickly change color\'s.
I want something to work like so:
#define GRAY
Daniel's answer is probably the best. Since he hasn't provided any code, this is one implementation:
-(UIColor*) colorFromString: (NSString*) colorName
{
static NSDictionary colors = nil;
if (colors == nil)
{
colors = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor darkGreyColor], @"GRAY",
[UIColor blueColor], @"BLUE",
// etc
nil];
[colors retain];
}
return [colors objectForKey: colorName];
}