I want to define constants NSStringand one of them refers to the other. For instance:
NSString * const kUrlGoogle = @"http://google.com";
NSString * const kUrlApple = @"http://apple.com";
NSString * const kUrlMicrosoft = @"http://microsoft.com";
NSString * const kUrlDefault = kUrlGoogle;
When I try to do this, I get a compile-time error in the line kUrlDefault:
The initializer element is not a compile-time constant
Is it possible to assign kUrlDefaultone of the lines above without resorting to using a macro?
Here are a few reasons why this might be useful:
- I could check for equality without calling a method
isEqual. - If I update a constant,
kUrlDefaultit will automatically get a new value (as with all constants). - Saving all constants in one file in one place.