Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Use Core Data for storage" checkbox

What actually happens behind the scenes when you select the "Use Core Data for storage" option when creating a new Window based project in Xcode? I'm trying to use Core Data in a project that I've already created, and I'm having a hard time figuring out how to include the framework properly in my Xcode project...

Thanks!

like image 381
James Sun Avatar asked Sep 18 '09 20:09

James Sun


1 Answers

In addition to importing <CoreData/CoreData.h>, there is a template which populates the application delegate implementation with the following methods:

-managedObjectContext
-managedObjectModel
-persistentStoreCoordinator

which initialize the applicaton's managedObjectContext, managedObjectModel and persistentStoreCoordinator members. (The application delegate header is populated with hints to these methods, the associated member variables and their property descriptions.)

The template also adds code to -applicationWillTerminate: which writes changes to the managedObjectContext.

The easiest way to figure out what to add (and, more importantly, why) is to go through the iPhone Core Data tutorial, which should be findable from the Apple Developer Center website via its search engine, or via your favorite search engine. I will not add links here, so as not to cause offense.

like image 123
Alex Reynolds Avatar answered Oct 23 '22 00:10

Alex Reynolds