When creating an iOS app there is more often than not some sort of Internet aspect to it. This has been something that I have been working on at the moment in my app. It could be loading content from a website (alienblue), opening up a wiki page in safari (MC-Splashes) or doing complex data uploads and downloads (Facebook). I’ve learnt that each one of these situations requires a different approach and level of involvement in managing connections.
Alien Blue interacts with reddit.com and presents its content in an iPad and iPhone friendly way. This means it must download the data from the site, load it into the app and present it. This is not particularly difficult to do because the website is either available or not available, and the app does very little uploading to the site. Reddit is mainly a consumer site where few people upload content for many to look at and comment on. So the app does not need to have much complex connection management for uploading posts. But when it does, it operates in a similar way to the Facebook system detailed below.
MC-Splashes is an app that displays all of the current Minecraft splash texts in an easy to use format. It was also the app I made to test the App Store submission system. Unbelievably, over 3000 people have downloaded it. Anyway, back to the point. One of its features is a button which when pressed shows the Wikipedia page on Minecraft splash texts in Safari. This requires no connection management at all as that is up to Safari. Simple.
The last example is the one I want to focus on as it is the one that best represents my own app. The official Facebook application is very heavy on user interaction and content sharing and therefore requires a lot of connection management. A classic example of this is the messaging system. If someone attempts to reply to a message and then their Internet connection cuts out there is an immediate problem. Facebook stores that message until it detects that the connection to the Facebook servers is established again. Then it can send it. This requires a local storage method (Core Data, text files or other) and a monitoring function which detects connection losses and reconnections and stores messages, statuses or likes etc. until the connection is re-established. This is exactly how I plan to solve the problem of connection management in my app. Store objects locally until they can be sent to the server.