¡@

Home 

2014/10/15 ¤U¤È 10:03:41

iphone Programming Glossary: another_url

Global constants in Objective-C

http://stackoverflow.com/questions/8031082/global-constants-in-objective-c

#import MyViewController.h #import Constants.h this doesn't works. see above for the error. static NSString const ANOTHER_URL NSString stringWithFormat @ @ @ BASE_URL @ path @implementation HomeViewController ... The code doesn't work and returns.. c ios5 global variables share improve this question Solution A Personally I would just use a function for ANOTHER_URL . Solution B If you really want a constant You should be able to use cstring concatenation rules via #define then pipe that.. rules via #define then pipe that through CFSTR defs.h extern NSString const BASE_URL extern NSString const ANOTHER_URL defs.m #ifdef DEBUG #define DEF_BASE_URL http www.example.org #else #define DEF_BASE_URL http localhost #endif NSString..