Re: Window 'close' action fails
Re: Window 'close' action fails
- Subject: Re: Window 'close' action fails
- From: Charles Steinman <email@hidden>
- Date: Fri, 15 Aug 2008 14:21:59 -0700 (PDT)
--- On Fri, 8/15/08, dct <email@hidden> 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 (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