SQLitePersistentObjects

Tagged:  

Programming the SQL database on the iPhone, SQLite3, with the C interface can be tedious.

Some people recommend FMDB from Gus Mueller but even that is a bit too low level. It feels a lot like a JDBC if you know some Java.

A little while back, after looking at various persistence frameworks, I started using SQLitePersistentObjects. Its a great little project started by Jeff Lamarche of "Beginning iPhone Development" fame. He gave a presentation at 360iDev and put his slides online .

The best thing about SQLitePersistentObjects (SQLPO) is that it is super easy to get started. Just subclass you data object from "SQLitePersistentObject", declare your properties and you are ready to call save and find. You don't have to create the database or define the schema or anything else. It handles common data types right out of the box and you can extend it with your own data types if necessary.

Some things to think about:

  • Memory management - SQLPO does not hide or solve memory issues for you. If you do a findAll on your database of images you are likely to run out of memory.
  • Performance - SQLPO does a lot more for you than the C interface or FMDB so it can be a bit slower. They are working on improving this. It may not be an issue for you application though if you are smart about indexes, careful with your queries, learn to use paired arrays and remember it is a phone and not an enterprise DB server.
  • Threading - I would like to have the user thread creating data and have another thread processing those records (perhaps uploading them). I don't known for sure if SQLPO is meant to be used like this and if it is safe for multiple threads to be accessing the framework concurrently.
  • Advanced Features - SQLPO is awesome but it is not Hibernate (yet). Some advanced features (lazy loading) have not been implemented yet. Again, I find it a lot better than other frameworks but don't let your expectations get carried away.

If you are looking for a persistence framework for the iPhone I suggest you take a closer look at SQLitePersistentObjects

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h2> <img> <p>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options