How to run application in debug mode and release mode with different api's in ios

前端 未结 2 837
野性不改
野性不改 2021-01-26 05:07

Please help me with this issue.I have to run my application in debug mode with one api starting with and in release mode I have to run another api starting with.

In debu

相关标签:
2条回答
  • 2021-01-26 05:21

    Let's try:

    #ifdef DEBUG
    #define LINK_API @"LINK THAT YOU WANT"
    #else
    #define LINK_API @"LINK THAT YOU WANT"
    #endif
    
    0 讨论(0)
  • 2021-01-26 05:36

    You should create a BASE URL string. This string should be set dynamically based on debug or release mode. Pre-processor macro can help you to decide the mode of the application.

    Once it is ready you should create rest of the URLs based on your need.

    NSString *baseURLString;
    #ifdef DEBUG
    baseURLString =  @"http://def.info/api/homeapi/";
    #else
    baseURLString =  @"http://abc.info/api/homeapi/";
    #endif
    
    NSString *serviceType = @"login";
    NSString *loginURLString = [NSString stringWithFormat:@"%@%@",baseURLString, serviceType];
    
    0 讨论(0)
提交回复
热议问题