I have a dictionary with color settings and tried this:
#define ColorWithString( x) [UIColor #x]
NSDictionary *settings = @{@"color" : @"whiteColor"};
UIColor *color = ColorWithString(settings[@"color"]);
I get an error Expected identifier.
I know there are some subtleties with string preprocessing. Maybe it is not even possible to send a dynamic message to a class. Any suggestions to make this work?
Take a look at what your macro expands to:
That’s obviously not legal Objective-C code. I think you could use
performSelector:in combination withNSSelectorFromString:…but why not do simply this?