I have a custom view in a Nib. The view programmatically creates a bunch of "objects" during initialization. These "objects" depend upon the document managed object context. Currently the "objects" are created in 'awakeFromNib'. It all works fine.

@implementation MyCustomView

- (id)initWithFrame:(NSRect)frameRect
{
     self = [super initWithFrame:frameRect];
     if (self) {
         // Currently do nothing here.
     }
     return self;
}

- (void)awakeFromNib
{
     // Create a bunch of "objects" programmatically which
     // depend on the document managed object context (which
     // is reachable at this stage of initialization).
}

@end

I would like to establish bindings in Interface Builder between the "objects" created by the custom view and some standard Interface Builder widgets. The problem is 'awakeFromNib' is called AFTER the bindings are established so the bindings never work.

Nib loading order.

     1. Load contents of Nib.
     2. Custom view receives 'initWithFrame:'.
     3. Establish outlets, action connections, and bindings.
     4. Custom view receives 'awakeFromNib'.

The problem would be solved if the "objects" were created in 'initWithFrame:' which happens BEFORE the bindings are established.

But I can find no way to obtain the document managed object context in 'initWithFrame:' because the window controller of the view is nil at this stage of initialization.

The Nib is loaded by a custom document window controller. The document managed object context is valid before the window controller is even allocated or initialized. But I can find no way to get this information to the custom view.

@implementation MyDocument

- (void)makeWindowControllers
{
     // document managed object context is valid
     MyDocumentWindowController *windowController;
     windowController = [[MyDocumentWindowController alloc] init];
     [self addWindowController:windowController];
     [windowController release];
}

@end

Any suggestions? Thanks.

--Richard Somers

_______________________________________________

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