• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Core Data App With Auxiliary Panel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data App With Auxiliary Panel


  • Subject: Re: Core Data App With Auxiliary Panel
  • From: Quincey Morris <email@hidden>
  • Date: Fri, 31 Jul 2009 23:28:17 -0700

On Jul 31, 2009, at 20:03, Richard Somers wrote:

I am having problems binding an auxiliary panel with the document's managed object context. The panel is in nib separate from the document nib. My code looks like this.

@interface AuxPanelController : NSWindowController
{
@private
   NSManagedObjectContext *managedObjectContext;
}

@implementation AuxPanelController

- (id)init
{
   if (![super initWithWindowNibName:@"AuxPanel"])
       return nil;
   return self;
}

- (NSManagedObjectContext *)managedObjectContext
{
   return [[self document] managedObjectContext];
}

In the AuxPanel.xib the array controller's managed object context is bound to the File's Owner managedObjectContext model key path. The File's Owner object is the AuxPanelController.

In the running application the auxiliary panel displays properly but an error message is produced: "Cannot perform operation without a managed object context".

You haven't said what you mean by an "auxiliary panel".

If you mean it's a sheet on the document window, then its window controller's "document" property will be nil. You should pass the document as a parameter to the AuxPanelController's initializer instead.

If you mean it's a freestanding window (whether NSWindow or NSPanel), the answer is the same: pass the document because there's no other way.

If you mean it's a secondary document window, then you need to add it to the document's list of window controllers. That would need to be done by whatever creates is -- typically the window controller of the main document window. After that's done, AuxPanelController can refer to [self document] and get the document.

Or, in all 3 cases, just pass the managed object context to the AuxPanelController initializer, and stash it in your otherwise unused instance variable.

_______________________________________________

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


References: 
 >Core Data App With Auxiliary Panel (From: Richard Somers <email@hidden>)

  • Prev by Date: Re: How do I delete NSCollectionView item on right click?
  • Next by Date: Surprise: -[NSInvocation retainArguments] also Autoreleases them
  • Previous by thread: Re: Core Data App With Auxiliary Panel
  • Next by thread: How do I delete NSCollectionView item on right click?
  • Index(es):
    • Date
    • Thread