Simplified UI Development with MonoTouch.SQLite

| by Jonathan Allen Follow 491 Followers on Mar 27, 2012. Estimated reading time: 1 minute |

A note to our readers: You asked so we have developed a set of features that allow you to reduce the noise: you can get email and web notifications for topics you are interested in. Learn more about our new features.

When working with iOS and MonoTouch, you may find yourself needing to display data from a SQLite table. While this can be done directly by building up your own UITableViewController, the process can be quite time consuming with quite a bit of boilerplate code. Jeffrey Stedfast has found a way to reduce simple table binding to what’s basically a single method with MonoTouch.SQLite.

MonoTouch.SQLite is a database aware UI library that is designed to make displaying table data easy. It starts with SQLiteTableModel class. Out of the box this model provides basic table access with sorting and filtering, so you don’t need to do anything with it when showing simple data. But if you need to use complex SQL, you can subclass it and override the SQL generation methods.

Next up in the stack is the controller itself. For those of you who aren’t iOS developers yet, Apple’s UI libraries require a strict adherence to the classic MVC pattern. For a table-like view, this means inheriting from the framework’s UITableViewController class. MonoTouch.SQLite handles most of the details for you via its subclass SQLiteTableViewController. In the sample application, you can see one merely has to implement the GetCell method.

End User Searching

In order to make it easier for end users to find information, MonoTouch.SQLite includes the ability to turn user entered strings into custom SQL where clauses. To do this one simply tags their data model properties with the attribute SQLiteSearchAlias. The same alias can be used multiple times, for example FirstName and LastName would probably be both tagged with the alias “name”. Then when the user types ‘address:"Newton, MA" name:Jane’ it would generate a where clause that looks for a match in the address column and either name column.

All this works with the iOS UISearchDisplayController, which is designed to wrap the aforementioned UITableViewController.

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread


Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you