How to get CFBundleShortVersionString as constant

I am adding parts to the constant base url string in my code as such:

#define BASE_URL @"https://example.com/developer/"
#define PHP_SCRIPT BASE_URL @"index.php"

      

so the resulting PHP_SCRIPT refers to https://example.com/developer/index.php

I am looking for a way to embed my application CFBundleShortVersionString

in this concatenation.
For example, if CFBundleShortVersionString is 1.12, I want the final URL to behttps://example.com/developer/1_12/

I know that CFBundleShortVersionString

can be accessed by

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

      

and

(__bridge NSString *)(CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleVersionKey))

      

but I need help to concatenate it into a constant string.

+3


source to share


1 answer


This should do it.



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

      

+4


source







All Articles