SQLite for the iOS SDK, two years later

Written by: | Posted on:

It's been two years since I first wrote on using SQLite for iPhone SDK. Since then, iOS has come a long way, especially when it comes to storing data. But still, much remains the same. For instance, FMDB is still a great way of accessing SQLite databases directly, and if you're most familiar with SQL and don't want to learn too much new stuff (learning Objective-C and Cocoa can be enough by itself), this is a great way to write your first apps.

But, with iOS 3.0 came Core Data, and I was so happy when it did. Marcus Zarra wrote a great book with PragProg that I wholeheartedly recommend: it's easy to read and thorough at the same time. I followed his workshop at NSConf '09, which was great, and I understand people have enjoyed the videos he and Scotty produced over at iDeveloper TV. I use Core Data in all my projects now, and its backed by SQLite, so I get a great mapping while having the performance of the database.

It being the year of the NoQL-databases, though, a post wouldn't be complete without saying you can now ditch SQLite all together and use CouchDB. CouchBase have made a developer preview of CouchDB for iOS that I'm looking forward to try out. CouchDB has great replication, but I still need to learn more about how to handle security and access to data so to not give all my application users the keys to the "castle".

Happy coding :-)

SQLite for iPhone SDK

Written by: | Posted on:

After asking on the MacRumors forums I was pointed back to FMDB that I had looked at a couple of days ago. FMDB is a Cocoa wrapper for SQLite3. I had a look at it, and after my initial difficulties, I found that I was trying a way to complicated way to use it for my iPhone applications. To add FMDB, simply do the following:

  • in XCode in your project window, rightclick your "Classes" and Add -> "New Group", call it FMDB
  • drag the files from src in the FMDB package into the new group
  • Rightclick Frameworks, Add -> "Existing frameworks", select /Developer/Platforms/Aspen.platform/Developer/SDKs/Aspen1.2.sdk/usr/lib/libsqlite3.dylib and press "Add"
  • Compile, smile and start using it :-)
Image Image

Father, husband, software developer, musician and photographer.


Get to know what I'm up to

© 2020 Niklas Saers Contact Me