0

I should separate Live and Dev URL. So, I write this code

#define _APP_MODE @"real"

#if APP_MODE == dev
#define _BASE_URL @"http://devmall.aaa.com/m/app/"
#define _URL_FROM_SAFARI @"http://devmall.safari.com"
#else
#define _BASE_URL @"http://m.aaa.com/m/app/"
#define _URL_FROM_SAFARI @"http://m.safari.com"

but it always return dev_url

What is the best way to make sure that the URL is separated by APP_MODE?

양홍범
  • 87
  • 8

1 Answers1

1

strings dont work in objC preprocessor AFAIK

... see also how to compare string in C conditional preprocessor-directives


what I'd do (and is common) is using integers

#import <Foundation/Foundation.h>

#define DEV 0
#define REAL 1

#define APP_MODE REAL

#if APP_MODE == DEV
#define BASE_URL @"http://devmall.aaa.com/m/app/"
#define URL_FROM_SAFARI @"http://devmall.safari.com"
#else
#define BASE_URL @"http://m.aaa.com/m/app/"
#define URL_FROM_SAFARI @"http://m.safari.com"
#endif

int main(int argc, char *argv[]) {
    @autoreleasepool {
        NSLog(BASE_URL);
    }
}

note: loose all the weird underscores :)) [if you can]

Daij-Djan
  • 49,552
  • 17
  • 113
  • 135