The question I asked myself, in your case, is “who has the“ basic data stack ”? The data itself is really the application area, isn't it? (CF Core Data on Mac, where you can have an application that can work with multiple documents at once, so the Core Data stack belongs to each document.)
In any Cocoa / Cocoa Touch application, an application delegate is usually the preferred means of customizing application behavior, which is why this is the natural place for the Core Data stack.
Now the problem that I suspect is that he doesn’t feel so constant to write things like:
NSManagedObjectContext *context = [(MyAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
What I usually do in these cases are write functions (not methods) like this:
NSManagedObjectContext *UIAppManagedObjectContext() { return [*(MyAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext]; }
I am writing a similar function for NSPersistentStoreCoordinator and NSManagedObjectModel . I put all these files in the .h / .m delegate files, as these are also application level objects.
Alex Aug 12 '09 at 18:30 2009-08-12 18:30
source share