So I am working on a learning project and I am trying to create a header file that contains a store of URL\'s so that you can just change a single flag to change from Debug
I think you are trying to define the same variable twice. How about this:
In your header:
#define DEBUG 1
In the init of your .m file:
#if DEBUG
URL = @"dev.myserver.com";
#else
URL = @"myserver.com";
#endif
Geoff: I have a need for this kind of conditional in my Mac App Store app for validating receipts, and I do it with a separate build configuration and a -D
flag. In Debug configuration, add a compiler flag something like -DDEBUG_BUILD
(Note the double D at the beginning and no space.) and then use
#ifdef DEBUG_BUILD
#define SERVER_URL_STRING @"http://dev.myserver.com"
#else
#define SERVER_URL_STRING @"http://myserver.com"
#endif
This way, you don't have to remember to swap that #define
each time you build for production. (You'll forget eventually. Everyone has.) -If you do it this way, then you don't need the @property
or the ivar declaration either.- Just saw you took these out already.
I think this should work
#define DEBUG 1
#if DEBUG
#define URL = @"dev.myserver.com";
#else
#define URL = @"myserver.com";
#endif