On Jul 16, 2009, at 12:51 PM, tmow...@talktalk.net wrote:

I have removed it completely and just called the longer winded [[NSApp delegate] managedObjectContext] when I need it. I suppose I could have set the ivar in the awakeFromNib when all NIB objects are guaranteed to have been instantiated.

In general, you are discouraged from retrieving resources such as this from the application delegate. Instead, you should pass resources directly to view controllers. This is the pattern shown in the Core Data templates and related sample code, e.g.

- (void)applicationDidFinishLaunching:(UIApplication *)application {

RootViewController *rootViewController = (RootViewController *) [navigationController topViewController]; rootViewController.managedObjectContext = self.managedObjectContext;
        
    [window addSubview:[navigationController view]];
    [window makeKeyAndVisible];
}


This typically makes your view controllers more self-contained and reusable.

mmalc

_______________________________________________

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

Reply via email to