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.
From around the web
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..
advertisement
- Why you have to be left in the dark on OS patches
- Is Microsoft mismanaging Windows on ARM?
- Dealing with spam surrogates
- Why 3G broadband can be better and cheaper than ADSL
- Is Twitter bad for business?
- Publishing your email address isn't a security disaster
- Why you'll need a fax machine to develop iOS apps
- Learning to adapt to the mobile web
- Why you shouldn't use WPS on your Wi-Fi network
- Disabled users suffer when software breaks the rules
- Laptop bag reviews: nine tested
- Sony VAIO T Series Ultrabook review: first look
- Revealed: the military standards and robots HP uses to test its laptops
- Windows 8: multi-monitors and double standards?
- Why is TalkTalk's year-old porn filter suddenly big news?
- Why are laptop screens so far behind mobiles?
- HP EliteBook Folio review: first look
- The shoebox-sized all-in-one printer
- Forget the Ultrabook: here comes the HP Sleekbook
- HP Spectre XT review: first look
- Autonomy's Lynch joins 27,000 on way out of HP
- ICO: no fines for breaking cookie rules
- HP set to slash up to 30,000 jobs
- Government sites to miss cookie deadline
- Microsoft tweaks multi-monitor support in Windows 8
- Apple patches Leopard, despite ending support last year
- Defra opens rural broadband funding applications
- BT's broadband sales surpass calls revenue
- Apple patches multiple security issues
- FBI warns travellers to beware attacks via hotel Wi-Fi
advertisement

