Skip to navigation
Real World Computing
iPhone 3GS

Writing iPhone apps using open-source software

Posted on 11 Jan 2010 at 10:50

Simon Brock takes a real-world look at open-source software for writing iPhone applications, and explains how to use it

It supports “just enough” SQL to allow a developer to set up tables and query them, and supports all the usual SQL statements on tables and relational joins. In a similar way to the networking libraries, there are low-level SQLite functions available: a number of SQLite wrapper libraries make it more useful, and you can write your own. Two notable ones that are worth a look are EntropyDB and Flying Meat DB (FMDB).
EntropyDB is an object database that enables objects to be stored and retrieved later on (there’s a similar persistence framework in the main OS, but EntropyDB is slightly easier to use).

If you’ve set up a complex object to model your app, you can store it away whole when the app exits and retrieve it later on with all its state intact. FMDB, on the other hand, is a more conventional SQL framework that uses a tool such as the SQL Manager for Firefox, with which a developer can set up an initial database with tables and distribute it with their application.

Subsequently, when the application is used, it can store results in those tables and retrieve them later. If I were writing a new application I could use such a set of tables, say, to store these columns for reading later offline. There are no restrictions on what an application can do with SQLite, so it can create or drop whole tables. That means an application can be written in such a way as to create new tables or modify old ones whenever it’s updated from one version to the next.

Complete applications
If you’re trying to learn how to write iPhone applications, a great place to start is by looking at other people’s efforts. There are quite a lot of open-source applications out there, and a few of those show some interesting techniques.

At the simple end of the spectrum is this Wikipedia application, although I found the wikiHowTo app slightly more interesting. It contains an SQLite database, carries out asynchronous network calls, and has some interesting features: choosing a random article by shaking the iPhone is quite fun. Another similar application is Twitterfon, which was an open-source Twitter client but has now become closed-source – however, there do seem to be copies of the source code still in circulation.

At the other end of the spectrum is Molecules, which allows the user to view and manipulate three-dimensional renderings of complex molecules. While this may not be something that most people do professionally, or for pleasure, it is bizarrely fun for a few hours, and digging into its source code will illustrate many important programming techniques.

And not forgetting…
I know I’ve written about it before, but I do need to mention PhoneGap again. PhoneGap is an open-source project that allows you to leverage your web app into a self-contained application.

In essence, you first create your web app using HTML and JavaScript, which you can test to see you have it working the way you want both in the iPhone emulator and on a real iPhone. Once you’ve done that you then wrap it into an Xcode project and create a “real” iPhone app from it.

What’s interesting is that you can add “Xcode only” facilities to your web app, so you can build some of the interface options in Xcode and then embed your web app into them.

1 2 3 4
Subscribe to PC Pro magazine. We'll give you 3 issues for £1 plus a free gift - click here

From around the web

Be the first to comment this article

You need to Login or Register to comment.

(optional)

Simon Brock

Simon Brock

Simon runs UK-based Wide Area Communications, the company behind websites such as The Spectator. He's a contributing editor to PC Pro and a fervent believer in open-source technologies..

Read more More by Simon Brock

advertisement

Latest Real World Computing
Latest Blog Posts Subscribe to our RSS Feeds
Latest News Stories Subscribe to our RSS Feeds
Latest ReviewsSubscribe to our RSS Feeds

advertisement

Sponsored Links
 
SEARCH
SIGN UP

Your email:

Your password:

remember me

advertisement


Hitwise Top 10 Website 2010
 
 

PCPro-Computing in the Real World Printed from www.pcpro.co.uk

Register to receive our regular email newsletter at http://www.pcpro.co.uk/registration.

The newsletter contains links to our latest PC news, product reviews, features and how-to guides, plus special offers and competitions.