views:

128

answers:

4

Hey.

Do you know if there is a simple database framework that is free to use in iPhone development?

I've tried to get my head around Apple's framework SQLite3-framework, but it is just too complicated. Why can't it just be like PHP and databases …

So basically, what I want is a framework that is simple to use and can handle databases.

Thank you.

+7  A: 

Core Data is Apple's method to persist objects on the iPhone. This is also the most common method for storing data when developing for OS X and future Apple technologies, so it's worth spending the time to learn. The Apple Docs (linked above) are the best place to learn about this since they don't get outdated easily. Additional tutorials can be found through your favorite search engine.

In addition to making persistence very easy to do, it offers the following benefits:

  • Only store objects in memory that you need, to save memory usage
  • Migration and versioning support
  • Graphical-based schema editor in Xcode
  • Automatic support for undo/redo
drharris
Thank you :) I will be using this instead, as this is more supported by Apple.
Emil
+5  A: 

Try FMDB. It's a neat wrapper around the sqlite c API.

http://gusmueller.com/blog/archives/2008/03/fmdb_for_iphone.html

Jasarien
Works, but you'd be better off using Core Data.
bbum
I'm going to accept this, because this was what I asked for in the question. However, I think I will be using Core Data instead.
Emil
+2  A: 

There's also PLDatabase.

A SQL database access library for Objective-C, initially focused on SQLite as an application database. The library supports both Mac OS X and iPhone development.

nall
+1  A: 

Google toolbox for Mac http://code.google.com/p/google-toolbox-for-mac/ also includes a nice little sqlite wrapper, in Foundation/GTMSQLite.h. It isn't included in the provided iphone .xcodeproj but it does compile if you add it and its (minor) dependencies to an iphone project. Two classes: a db handle, and a prepared statement/resultset, with the expected methods on each.

Approach Core Data with caution: it is powerful, but confusing, and understanding O-R frameworks like Hibernate is a huge help. Use it if you have a complicated domain model already designed, and want some help persisting it to disk and keeping it consistent. If your data is already designed in terms of tables and joins, and/or your backing store needs to be portable to the non-Cocoa world, a suitably wrapped SQLite is still an excellent choice.

rgeorge