views:

26

answers:

1

I'm implementing a new iPhone app and am relatively new to Cocoa development overall. I am at the stage of choosing how the persistence layer of this app will work, and it looks like I'm basically choosing between Core Data and sqlite3.

The persisted models in this app are intended to have a schema that is loaded at runtime (from some kind of defn file, probably XML). By which I mean, this app is intended to have objects that are user-definable to some extent, e.g. the Customer type (which has certain built-in fields like "name" and "email") can be modified to have extra fields based on the user's specific needs (e.g. a user might want to add a "favourite fruit" field to their Customer type).

Having said that, will Core Data work for an app with a non-baked-in data model like this? I've just started playing around with the Core Data object designer thing in XCode and it seems like this thing wants to work with objects that have fixed fields that are compiled in.

I'm definitely trying to take the path of least resistance here, and I can see the benefits of using an Apple-supplied data framework, but don't want to start down that path if it's going to lock me into a data model that's defined at compile time.

+2  A: 

The Core Data data model needs to be defined at compile time, but that does not mean you can't allow for custom fields to be added and used by end users.

It just means that you would define an entity for custom fields and create the fields as objects.

It is best to design a data model that meets your needs rather than think of how you would solve the problem in SQL.

gerry3
Thanks for the response Gerry. It looks like I will probably take the time to learn Core Data, although I was definitely keen in the original design to avoid any distinction between the implementation of "core" fields and user-defined ones. This just creates a splintered impl that has to always cope with the two types of data in an object, whereas I was hoping to have all fields treated the same for conciseness of impl, although perhaps the conveniences of using Core Data will outweigh the hassle of having the two-pronged data model.
glenc