Objective-C Macro Redefinition

dns, iphone, macros, objective-c, rest

Solution

`#undef` is your friend:

#ifdef __LIVE_TESTING

    #if defined(DOMAIN) && defined(DOMAINCOMET)
        #undef DOMAIN
        #undef DOMAINCOMET
    #endif

    #define DOMAIN @"http://192.168.10.229/rest/"
    #define DOMAINCOMET @"http://192.168.10.229/"

#endif 

Problem

I am currently using three servers (deploy, live_testing, and local). I am using macros to define a serie of domain locations: ``` #define __LIVE_TESTING // Here I chose what domain to use #ifdef __PRODUCTION #define DOMAIN @"http://192.168.10.228/rest/" #define DOMAINCOMET @"http://192.168.10.228/" #endif #ifdef __LIVE_TESTING #define DOMAIN @"http://192.168.10.229/rest/" #define DOMAINCOMET @"http://192.168.10.229/" #endif ... ``` The issue I am having are compiler issues relating to the redefinition of DOMAIN and DOMAINCOMET. Is there a workaround for these warnings? Thanks in advance, Clinton

Original source