In my development I wish to hit a development URL when im testing but when the app is run on my iPhone, I want it to run on production URL. How do I get about setting this i
You can also set the different URLs in your plist file by adding new String rows if you don't want to use a constants file.
(Not much to be gained here though I admit but depends on where you prefer to set up your urls)
In your myApp-plist file add new rows like this:
"DevelopmentEndpoint" "String" "http://development.endpoint.com"
"ProductionEndpoint" "String" "http://production.endpoint.com"
In your code:
// Get endpoint from main bundle
#ifdef DEVELOPMENT
NSString *endpoint = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"DevelopmentEndpoint"];
#else
NSString *endpoint = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"ProductionEndpoint"];
#endif
In your build settings add DEVELOPMENT under the "Preprocessor Macros" section for Debug or Release etc.