I don't believe that my 'close' problem is explained by an awkward init -- as I said before, all of the other U/I operations of the nib "SPlotWindow.nib" are working as expected (so somehow I've dodged a potential bullet, at least so far).

Re: "[splotView setFrame:NSMakeRect(50,50,50,50)]; // or whatever you want the frame to be" I need for the rectangle to conform to a Custom View (class:SPlotView) which is located on the window defined by SPlotWindow.nib and I'd rather not have to (remember to) modify a bit of code (i.e., "set frame"...) whenever I make an Interface Builder change to the nib.

I do wonder why it is improper to:
  1. load a nib, then
  2. init a WindowController instance using that nib, and then
3. init an NSView instance defined as part of the nib using the nib defined frame
all within a subclass init method.

Thanks for the help.  Don

On Aug 15, 2008, at 2:21 PM, Charles Steinman wrote:

--- On Fri, 8/15/08, dct <[EMAIL PROTECTED]> wrote:
Both classes implement 'init' in like fashion
(using different nibs
and different NSView subclasses/connections):

- init
{
        [NSBundle
loadNibNamed:@"SPlotWindow.nib" owner:self];
        [super
initWithWindowNibName:@"SPlotWindow.nib"];
        [splotView initWithFrame:[splotView frame]];
        return self;
}

I don't know if your trouble is related to this, but that init method is a little messed up.

1. You shouldn't be performing any actions on an instance that hasn't been initialized (as in the first line of that method) -- I think it will work sometimes, but it's not particularly safe. 2. You shouldn't be calling init... methods on objects that haven't just been alloced (as in the third line) -- or, alternatively, you shouldn't be asking an object that hasn't been initialized for its frame (which is how the third line would read if splotView had just been alloced).
3. You can't reliably message objects in a nib before -awakeFromNib.

It ought to be something along the lines of:

- (id)init
{
 return [super initWithWindowNibName:@"SPlotWindow" owner:self])
}
- (void)awakeFromNib
{
[splotView setFrame:NSMakeRect(50,50,50,50)]; // or whatever you want the frame to be
}

Cheers,
Chuck




_______________________________________________

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