Search code examples
iosnsurlconnectionnsurlnsurlrequest

Update base URL in my App if server changes


Suppose I am making a server call using NSURLRequest and NSURLConnection. I am making call to URL such as "http://www.testAAA.com.au/methodName". Now user installed my App. Few days later, I needed to change base URL. For example: "http://www.testAAA.com.au" to "http://www.testBBB.com.au".

In short, just base URL is being modified. I need to set such a mechanism that once server base URL changes, App can update base URL in the next call made for device. I have taken a constant for base url. So, next time the App makes any call to old base URL, I need to update that base URL with new one.

Is there any trick I can use?


Solution

  • Suppose you have const NSString *baseURL; in your Constants.h file, then in didFinishLaunchingWithOptions you can set your baseURL with the new one, this will update the url when user restart the app.