[Look for edit below]
I would use a lookup table. In this case a dictionary that will hold the possible values as key's and the values as UIColor objects. Such as :
NSDictionary *colorTable = @{
@"blackColor" : [UIColor blackColor],
@"greenColor" : [UIColor greenColor],
@"redColor" : [UIColor redColor]
};
So that way when you want to "convert" a color string, you would :
UIColor *myConvertedColor = [colorTable objectWithKey:@"blackColor"];
myConvertedColor will be a UIColorBlack.
Hope this helps!
Good Luck!
--->>EDIT<<----
Ok, here's tested code. Try it somewhere clean so that you won't get interference from other things that might be running. Note that I am asuming iOS.. Otherwise change UIColor for NSColor..
NSDictionary *colorTable = @{
@"blackColor" : [UIColor blackColor],
@"greenColor" : [UIColor greenColor],
@"redColor" : [UIColor redColor]
};
UIColor *myConvertedColorNull = [colorTable objectForKey:@"whiteColor"]; //NULL
UIColor *myConvertedColor = [colorTable objectForKey:@"blackColor"]; //NOT NULL
NSLog(@"MyColor: %@", [myConvertedColor description]);
NSLog(@"MyColorNULL: %@", [myConvertedColorNull description]);
This produces this output:
MyColor: UIDeviceWhiteColorSpace 0 1
MyColorNULL: (null)
As you can see, the MyColorNULL is to prove how you should not do the search, while the other proves that my code works.
if it helps, please tag my answer as correct. If it doesn't let's keep working it out.