Hi, Whats the best way to pass a NSManagedObjectContext object from an app delegate to other view controllers?
Currently, my NSManagedObjectContext is retained like this in my app delegate: @property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext; @private NSManagedObjectContext *managedObjectContext_; } and in my implementation: - (NSManagedObjectContext *)managedObjectContext { if (managedObjectContext_ != nil) { return managedObjectContext_; } NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; if (coordinator != nil) { managedObjectContext_ = [[NSManagedObjectContext alloc] init]; [managedObjectContext_ setPersistentStoreCoordinator:coordinator]; } return managedObjectContext_; } In my view controllers, I create another NSManagedObjectContext Object and pass the reference like this: @property (nonatomic, retain) NSManagedObjectContext *context; Implementation: CameraPlanAppDelegate *appDelegate = (CameraPlanAppDelegate *)[[UIApplication sharedApplication] delegate]; context = [appDelegate managedObjectContext]; Is this correct? Do I need to release "context" on my view controller? If I release it, don't I release all references to it? Thanks. Phil_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com