Re: NSController controllerEditor:didCommit:… exception
Re: NSController controllerEditor:didCommit:… exception
- Subject: Re: NSController controllerEditor:didCommit:… exception
- From: Kyle Sluder <email@hidden>
- Date: Mon, 15 Nov 2010 10:24:04 -0800
On Nov 15, 2010, at 5:32 AM, Vincent Habchi <email@hidden> wrote:
>
> Yes, the MOC is provided through a binding to the AppController, itself part of the NIB. But the MOC iVar is set to nil until the user successfully opens a persistent store file. So I imagine the init code for the NSArrayController protests against finding a MOC set to nil. But since I don't actually need the array before the MOC is initialized, ignoring the exception it raises does not lead to a fatal error.
>
> I worked around this annoyance by opening a temporary MOC. I imagine I could also decide to remove the controller from the NIB and create it programmatically only when a proper store is opened.
This sounds like a perfect candidate for factoring out your MOC-dependent UI and loading it only after the MOC has been successfully created.
If your app is simple enough, your app delegate could initialize the MOC and act as the nib's File's Owner. In more complicated applications, I would instead recommend the app delegate still be in charge of creating the MOC, but also creating an NSWindowController that loaded the window's nib and acted as File's Owner. This is quite like the NSDocument architecture.
--Kyle Sluder_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden