Ios 如何将CbundleShortVersionString作为常量

Ios 如何将CbundleShortVersionString作为常量,ios,version,nsbundle,compile-time-constant,Ios,Version,Nsbundle,Compile Time Constant,我在代码中将部分附加到常量基本URL字符串,如下所示: #define BASE_URL @"https://example.com/developer/" #define PHP_SCRIPT BASE_URL @"index.php" 这样得到的PHP_脚本引用https://example.com/developer/index.php 我正在寻找一种方法,将我的应用程序的CbundleShortVersionString插入到这个连接中。例如,如果CbundleShortVersion

我在代码中将部分附加到常量基本URL字符串,如下所示:

#define BASE_URL @"https://example.com/developer/"
#define PHP_SCRIPT BASE_URL @"index.php"
这样得到的PHP_脚本引用
https://example.com/developer/index.php

我正在寻找一种方法,将我的应用程序的
CbundleShortVersionString
插入到这个连接中。
例如,如果CbundleShortVersionString为1.12,我希望最终URL为
https://example.com/developer/1_12/

我知道,
CbundleShortVersionString
可以通过

[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"] 

但是我需要帮助将它连接成一个常量字符串。

这应该可以

#define BASE_URL @"https://example.com/developer/"
#define PHP_SCRIPT [NSString stringWithFormat:@"%@%@/", BASE_URL, [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"] stringByReplacingOccurrencesOfString:@"." withString:@"_"]]
#define BASE_URL @"https://example.com/developer/"
#define PHP_SCRIPT [NSString stringWithFormat:@"%@%@/", BASE_URL, [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"] stringByReplacingOccurrencesOfString:@"." withString:@"_"]]