일정

2014-08-27 5 views
3

내가 같은 내 코드에서 일정한 기본 URL 문자열에 부품을 추가 A와 CFBundleShortVersionString을 얻는 방법 :일정

결과 PHP_SCRIPT가 참조하는
#define BASE_URL @"https://example.com/developer/" 
#define PHP_SCRIPT BASE_URL @"index.php" 

같은

https://example.com/developer/index.php에 내가 찾고 있어요 내 응용 프로그램의 CFBundleShortVersionString을이 연결에 삽입하는 방법. CFBundleShortVersionString가 1.12 인 경우 예를 들어, 나는 최종 URL 내가 CFBundleShortVersionString

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

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

에 액세스 할 수 있다는 사실을 알고 https://example.com/developer/1_12/

되고 싶어하지만 난에 도움이 필요 상수 문자열로 연결하십시오.

답변

4

이렇게해야합니다.

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