I would like to know how the following works in Objective-C
-
in my header file i have the following which is initialized from a different view controller
@interface UserLookup : UIViewController { NSManagedObjectContext *referringObject; }
and in my implementation file i have to pass this NSManagedObjectContext to 2 child view controller then does it make a difference which view controller is called first… and does the NSManagedObjectContext changes in any one of the child controller?
Regards
You don’t really need to pass it around to every view controller where you will need Core Data access – just use
managedObjectContextmust be an accessible ivar of your app delegate.It makes it conceptually similar too. There is one NSManagedObjectContext (in most uncomplicated apps, thought you can have multiples), owned by your app delegate. You don’t ever retain or release it (except for when it is created in the app delegate, on first access if you are using Apple’s template code, and when it is released in app delegate’s
dealloc.