On Aug 19, 2008, at 21:39, R T wrote:

> I have a Core Data Document-based Application.....a document window  
> with a tableview, a text view and a button. When the button is  
> selected,  a number is read from the text field and that many  
> objects are programatically added to the tableview. Then a sheet is  
> opened. The tableview presents only part of the attributes of an  
> entity. The sheet will present the remaining attributes in it's own  
> tableview.
> My problem is that I need the sheetController to have access to the  
> myDocument.h instance variable,  NSArrayController *tableController,  
> which is bound to the managedObjectContext. I'm having trouble with  
> this. Is the instance variable of the document available to the sheet?

> Quincey Morris wrote:

> The easiest way is probably to subclass NSWindowController, putting  
> the sheet window in its own NIB file and setting the class of File's  
> Owner to your window controller subclass. Your window controller can  
> be initialized with any properties you need (such as the document),  
> which means you can bind various interface items in the NIB file  
> through File's Owner.document (or whatever).

> I wouldn't recommend referring to objects in the underlying window's  
> interface in your sheet. (So, don't refer to document.tableController  
> from the sheet.) Instead, make properties of your document object that  
> contain the data that the sheet needs.



So How do I make properties of the document object that contain the data that 
the sheet needs?

I have tinkered on this for a week & a half. No Luck! I've subclassed the 
NSWindowController, put the sheet window in its own NIB file and set the class 
of File's Owner to your window controller subclass. The MyDocument nib now 
contains an AppController.
----------------------------------
This is AppController.h

     #import <Cocoa/Cocoa.h>
     @class AmtSheetWindowController;
     @interface AppController : NSObject {
             AmtSheetWindowController *amtSheetWindowController;        
     }
     - (IBAction)showAmtSheetPanel:(id)sender;
     @end

This is AmtSheetWindowController.h

     #import <Cocoa/Cocoa.h>
     @interface AmtSheetWindowController : NSWindowController {
             IBOutlet NSArrayController *amtSheetTableController;
     }
     @end
----------------------------------
The AppController is in the document xib and the showAmtSheetPanel method opens 
the other xib and shows the sheet.
----------------------------------
     This is MyDocument.h...

     #import <Cocoa/Cocoa.h>
     @interface MyDocument : NSPersistentDocument {
             NSManagedObjectContext *moc;       
     }
     - (IBAction)doSetup:(id)sender;
     - (void)setZone:(int)value:(id)nObject
     @end
----------------------------------

So I think that the NSManagedObjectContext *moc is the property of the document 
that the sheet needs. How can amtSheetWindowController be initialized with this 
property? How can I bind amtSheetTableController in the XIB file ?






      
_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to