Initialiser element is not a compile time constant

ios, ios4, ios5, iphone

Solution

The problem is that NSLocalizedString is a function which returns different values, depending on the language. It is not a constant which can be figured out until the system is running.

Instead, use:

 #define ALERT_OK NSLocalizedString(@"Ok",@"Ok");

And it will now simply replace ALERT_OK with the function and you will be fine. (Note that you should be using some kind of prefix to all global values like this so that you don't accidentally create something with the same name being used somewhere else.)

Problem

In my constant file, I have included the below line ``` NSString * ALERT_OK = NSLocalizedString(@"Ok",@"Ok"); ``` After this, when I tried to compile I am receiving the below error ``` Initialiser element is not a compile time constant ``` How can I debug this?

Original source