iPhone news reader application
We have recently developed an iPhone application for one of our web portal clients based out of United Kingdom. The application talks to the custom news reader via a web service (LAMP stack) to display the recent updates in a pictorial grid based view. On clicking a picture the iPhone application retrieves the associated news article. It also allows the user to view the news based on categories.
Challenges – work around and issues solved
Slow loading of images
The application loads the latest news in pictorial grid format. When we used synchronous loading the launch of application was really slow. So, the only possible way to load images without hampering the application loading time was asynchronous loading. Even when the application was launched the user felt that it was still being launched as images were still being loaded. Therefore, the user couldn`t interact with the application.
So we tried creating a new thread (apple recommends avoiding threads) dedicated for image loading. But putting a thread into a different auto release pool, caused unexpected crashes. Initialization of connection and loading images took more time than expected. Our aim was to load images as fast as possible and reduce inconsistency and yet retain the features provided by application. The solution was to remove the imageview and use a webview (used to load web pages) of the size of imageview and programmatically inject an html page with just the corresponding image inside it.
Dynamically loading images in Grid format on scrolling
We wanted dynamic loading of images enabled. The idea was that images were loaded whenever the user scrolled down for more images. We needed to know when the user scrolls down whether we need to download the images. This is because the user could have earlier scrolled down and the application would have already fetched those images.
A way to implement it was to parse the XML file for the next nine images when user scrolls down for more images (if not already downloaded). We then check whether the scrolling is going beyond a certain threshold (which multiples as the number of images being displayed increases). Then we increase contentsize of scrollview and insert images into it in grid format.
Translucent tree structured Menu
Since there was no translucent tree structure menu for the application we developed one. The problem we faced here was that when views were expanded selection of sub menus weren't happening. Later it was found out that even though the view size was increased its superviews size wasn't getting increased. So the events on the view weren't getting caught. So it is a must that to catch the event of a view it should be perfectly contained inside its superview.
Checking network connection
A network based application it is supposed to give the end user network status details. So we implemented a network status checking class using SCNetworkReachabilityRef. It checks Wi-Fi and Internet connection, but can't guarantee whether the server is available. It just checks whether request was being sent out of the device. So we had to implement another function to confirm that the server is up using NSURLConnection. This enabled us to setup a custom timeout.
Best practices for iPhone development
We have setup continuous integration using HUDSON. This is to prevent integration errors and to have a build version is ready whenever integration is done to the application. Each time a build is done in HUDSON a static code analysis using scan build is done over the source code. Used performance tool to monitor memory leaks and ensured that application had low memory leaks.
Also read Android and iPhone development
