--- On Fri, 8/15/08, dct <[EMAIL PROTECTED]> wrote:

> 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).

I agree it seems a little odd, but it's possible, and that's all that I could 
find wrong from the code you posted. Have you tried checking to make sure the 
controller's window is what you think it is (say, logging [self window] at 
various points)? If it lost track of the window somehow but maintained all of 
its NSBundle-established bindings, that could explain what you're describing.

> 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.

Well, the point is that the view is already created at that point, so it should 
be setFrame: to set the frame. Also, you're setting splotView's frame to 
[splotView frame], which by definition it already is.

> I do wonder why it is improper to:
>    1. load a nib, then
>    2. init a WindowController instance using that nib, and
> then

Loading a nib is fine, but there are a couple of gotchas in this particular 
case. First, you're loading stuff from the nib TWICE -- once with NSBundle, 
then with NSWindowController's initWithWindowNibNamed: -- which is why I 
suspected you might not be controlling the NSWindow instance you think you are. 
Second, you're making the NSWindowController the owner of the nib objects 
before it's been fully created (i.e., before you run init...). This might work, 
but it's just luck if it does. That's undefined behavior. There's no guarantee 
that the object returned by initWithWindowNibName: will even be the same 
instance the message was sent to.

>    3. init an NSView instance defined as part of the nib
> using the nib  
> defined frame
> all within a subclass init method.

The init method is part of Objective-C's object creation. It's only meant to be 
run once, immediately after an alloc method. This object has already been 
created by the nib loader, so it doesn't need an init method. If you want to 
set its frame, setFrame: is the way to do it. Also, you can talk to objects in 
the nib right after you load them with NSBundle, but if you use 
[[NSWindowController alloc] initWithWindowNibName:owner:] (which is intended 
for exactly what you're doing), you won't be able to communicate with objects 
in the nib until -awakeFromNib.

Hope that helps.

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