Possible Duplicate:
how to convert nsstring to uicolor?
not an objective-c programmer but am not sure if I can’t do something like this. I know I’m returning a string value but just want a terse way of getting at these values:
NSMutableArray *colorsArray=[[NSMutableArray alloc] init];
[colorsArray addObject:@"whiteColor"];
[colorsArray addObject:@"blueColor"];
// val5 is either 0 or 1
[view setBackgroundColor:[UIColor [colorsArray objectAtIndex:val5]]];
Is this possible?
thx in advance
Why don’t you store directly colors instead of
NSString?You code as it is doesn’t compile, syntax is invalid since you are trying to do
[UIColor @"whiteColor"]which is not a valid syntax. You could useperformSelector:but this is senseless unless you really need to store colors as strings.