Untitled UI logotext
Solutions
WebsitesEcommerceMobile AppsWeb AppsProduction Support & Maintenance
Our work
Company
About usBlogPodcastContact us
Book a free consultation

Simplifying NSURLConnections in iOS

Olivia Rhye

Chances are, if you are creating an app in iOS, you will at some point be interacting with a connection to the server. All asynchronous requests need two components: the call, and when the connection receives data.

If you're using an API, you will probably run into the need at some point to post to multiple URL's having the same base and yet perhaps in multiple environments, one for testing and one for production.

If that is the case, you will need to set the base URL somewhere in your code. I chose this function:


- (void)applicationDidBecomeActive:(UIApplication *)application {
}

If you save your URL here as an NSUserdefault, you will be able to easily call up the URL wherever you need it. Then if you need to change your URL, you don't have to update it in multiple places in your code.

Ready to start a project?

Book a free consultation
Untitled UI logotext
Our work
About us
Blog
Careers
Submit a ticket
Agency Partnerships
Contact
© 2024 fjorge. All rights reserved.
Privacy