下面是我用来选择IP的宏。弹出一个alertview,用户尝试登录,因为相应的IP设置为从服务器获取数据。
static NSString *updateProfileDetails_URL=@"http://%@/api/Home/editProfile/ios/1";
#define getServerURl(url,selectdServer)[[NSString stringWithFormat:@"%@",url] stringByReplacingOccurrencesOfString:@"%@"
withString:([selectdServer isEqualToString:@"live"] ?@"live_ip/folder_name":@"demo_ip/folder_name" )]
由于
答案 0 :(得分:1)
您可以尝试这样:
#define USE_TEST_URL 1 // use 1 for test and 0 for live
#if USE_TEST_URL // define test urls here
#define API_URL @"http://...<TEST URL>"
#else // define live urls here
#define API_URL @"http://... <LIVE URL>"
#endif
和
NSString *url =[[NSString stringWithFormat:@"%@",API_URL] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
答案 1 :(得分:1)