I've recently created a project using Core Data. I checked where xcode ask you if you want to use Core data or not and I have the core data generated code in my app delegate. I've gotten it to work after many hours of doing research. Here is what I've done to get it to work:
- created an instance of the managedObjectContext in the app delegate
pass that instance to an object that would be doing Core data calls for instance
managedObjectContext = [self managedObjectContext ];
//the above code initializes all the other generated variables on the MOCDBLayer dblayer = [[[DBLayer alloc] init];
dblayer.moc = managedObjectContext;
You would think that you could copy all the generated code from the app delegate to a new object and it would work fine, but it didn't for me.
So, basically my question is do you have to create the managedObjectContext in the app delegate and pass it around to whomever needs it or is there a simpiler way?
The reason I ask is because there are some objects that need to make database calls and I've having to pass the instance of managedObjectContext to them from the app delegate.
Thanks to all that reply