In today’s post I’m not going to talk about New Sokoban development 🙂 A few weeks ago I got the opportunity to work on a project for developing and iOS universal app. So, today I’m going to talk a little bit about the development of this app called Trucoteca and developed with Trucoteca.com.
A few weeks ago I had the opportunity to work with the Trucoteca.com guys. On their videogames site, they offer a bunch of services including a huge database of videogames cheats for all platforms. So releasing an iOS universal app to offer this cheats database via Apple’s devices was something that they should be interested on. And yes there were 🙂 The main requirements were very clear:
- Must be an universal app, with specific UI design for iPad and iPhone/iPod.
- The database must be available offline.
- Needs to have an automatic and transparent updates system for the cheats database.
So, as you can see, things were very clear from the very beginning. That made my life a lot easier. You can see a video of the app at the end of this post.
As you can see on the video, it is a very simple app. It needs to be simple because you probably will use it while playing a game on your favorite desktop console or event with a handheld one. So, information needs to be available as soon as possible. No room for fancy screens or irrelevant information.
The main view is a TableView with a navigation bar. You can filter the games displayed on the table view by platform using the right button on the navigation bar. When you select a game, the app navigates to the specific view which displays all the cheats information about this game in a WebView. A WebView is the easiest way to implement it because the cheats information for every game is stored into Trucoteca.com servers as a piece of HTML code.
Although it is a little app, there are a few issues that needed to be adressed that were quite new for me on iOS development. I’m going to explain them a little bit.
Huge TableView Management
The first thing I was afraid of when thinking about this app, was the huge amount of information these guys have on their databases. I had already been using table views in my projects but never needed to manage such a large amount of rows. About how many rows would a table view be able to manage with no performance issues? Well, I really don’t know but there were not big problems managing the almost 15.000 rows needed for Trucoteca.
However, I couldn’t manage to include row animations without going into serious performance problems. I planned to include row animations when you filter the rows by platform. When you do that, the table view needs to be refreshed and it is nicer if you do it with a smooth animation. However, the performance dropped drastically so I finally decided to do it without animations.
Using SQLite on iOS
That was my first time using SQLite database on iOS. And I have to admit that there were no relevant problems implementing it. The only thing that needed a bit more of work was related to the fact that the app needed to be released with an up to date version of the database (to avoid the user wait the first time he launches the app). So, I needed to make an initial fake update to download all the database, then look for this new sqlite file on my Mac file system, include it into the bundle and finally copy it into the device the first time the user launches the app.
Here you have the code snipped I used to copy the database file from the app bundle to the device file system:
self.databaseName = @"your_db.sql"; // Get the path to the documents directory and append the databaseName NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDir = [documentPaths objectAtIndex:0]; self.databasePath = [documentsDir stringByAppendingPathComponent:databaseName]; // Get the path to the database in the application package NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:databaseName]; // Copy the database from the package to the users filesystem [fileManager copyItemAtPath:databasePathFromApp toPath:databasePath error:nil]; [fileManager release];
Designing an automatic updates system
I have always used the Apple’s free updates system on all my iOS projects. However, in Trucoteca it just has no sense to bother the user with new updates including a pack of new cheats. How often do you offer these updates? If the updates are too frequent, you are bothering the user. But if the updates are too spaced in time the user is not up to date.
So, in this case, an in-app update system was needed. Moreover, it needed to be transparent to the user. So, every now an then the app checks if there are new cheats on the online database and downloads them in background.
The Trucoteca.com servers are ready to serve this information through a PHP script. So, I didn’t even needed to query the online database. I only needed to download to correct HTML file through the corresponding PHP service, parse it and insert the new information into the internal SQLite database.
So, I used NSURLConnection to download the new cheats asyncronously. I parsed it manually, without using a third party parser because the file format is not standard. Finally, I start a new thread to store the new information into the database.
All these processes can be done in background without the need for the user to notice it. However, the table view needs to be refreshed and this can’t be done in background. I could have done it when, for example, the app is re-launched or comes back from background. However, I finally decided to update the table view immediately after the new information is available and inform the user (with an alert view) about that the information on the screen is going to be updated.
Moreover, I use this alert view to inform the user about that he can disable automatic updates via the device Preferences. There is people that doesn’t like that the apps connect to the Internet without their control.
iPad Split View
Trucoteca is an Universal app. And, although I could just used the same iPhone UI design with the standard navigation bar and navigation system, there is an iPad-only control that perfectly suits into this app: the Split View control. This was my first time with this iPad control but its implementation was quite straight forward. I mostly followed this great tutorial from Ray Wenderlich, an awesome iOS indie dev. Great! 🙂
Trucoteca is already available for free on the App Store here. It is a simple but handy and useful app. It is only available in Spanish because the Trucoteca.com site and database is in Spanish.
Working with Trucoteca.com people has been just great. Very kind guys and very responsive when I had technical problems during the development.