views:

2477

answers:

2

There are too many options for creating projects in XCode,

But When we select Navigation Based Application / Window based Application

We can see the extra option - Use Core Data For Storage.

I need brief detail about it.

What's new in it?

+5  A: 

Core Data is essentially a way to build your model visually, a sort of Interface Builder for the model. You create entities that represent model classes, and define relationships between them. Instead of having to code up a Person class that has an instance of an address class, you can just create them visually by dragging and dropping. There is lots more to it than that, but that is a main feature that I think is cool.

Also see this Apple documentation.

Jergason
+6  A: 

To elaborate on what Jergason wrote. Core Data is an Object-Relational Mapping (ORM) similar to Hibernate in the Java world. It abstracts the actual mechanics of storing data (such as SQL or .plist files) away from your code. Your code just needs to deal with a consistent object oriented framework to fetch objects, update them and persist them. Core Data supports some level of ACID transactions, but not 2-Phase commits. On the iPhone, the default settings for Core Data wrap the sqlite databases with the ORM layer.

One of the interesting side benefits of using Core Data is the tool to visually design your data model and to generate the model classes. If you have a large model this can save alot of time in hand coding model classes.

Another interesting benefit of Core Data is it's ability to migrate your database from one model version to another. This is very important in the iPhone world since you may want to modify your data model from one version of your app to the next. Core Data provides a pretty straightforward way to migrate the persisted data from the old model to the new without you having to write a ton of migration code. You just define a migration map and add a 'few' lines of code to your app delegate and things get converted for you.

Core Data on the iPhone is designed for the mobile environment. If you fetch all the rows in a table into an array it doesn't actually pull everything into memory. It creates what Apple calls a faulting array which is just an object that looks like an NSArray. When you access the various elements of the array Core Data fetches those entities (rows) on use, not on query. It saves memory and helps your app run faster.

All-in-all it's a pretty full featured ORM layer, not as rich as Hibernate, but sufficient for this environment.

Jack Cox