Re: Window 'close' action fails
Re: Window 'close' action fails
- Subject: Re: Window 'close' action fails
- From: Keary Suska <email@hidden>
- Date: Fri, 15 Aug 2008 19:29:57 -0600
- Thread-topic: Window 'close' action fails
8/15/08 4:28 PM, also sprach email@hidden:
> 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).
Yes, you have been lucky. The code presented is not just awkward, but
entirely wrong and crash-prone. It violates the most fundamental concepts of
Objective-C object construction. I recommend that you gain an understanding
of these concepts before proceeding any further with Objective-C
programming.
In any case, there is likely insufficient code to determine the nature of
your problem, but the errors you have already coded could lead to
unpredictable results, and should be corrected first.
Also, you should be calling -performClose: on the controller's window
instead.
> 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
Because NSWindowController does its own nib loading and management. And it
will do it better than you can--trust it. You probably have one hell of a
memory leak, though ;-)
> 2. init a WindowController instance using that nib, and then
Because you aren't--i.e. what you describe is not how a window controller
works. You should familiarize yourself with the NSWindowController interface
(i.e. API docs).
Now the self = [super init] idiom may be debatable, but you will be happier
if you follow it. Otherwise that line of code is fine.
> 3. init an NSView instance defined as part of the nib using the nib
> defined frame all within a subclass init method.
Everything defined in the nib has already been instantiated, and you should
never call an init method on an object that has already been inited. And
what is splotView? Is it an outlet? If so, it has not been connected yet so
that line of code is a complete no-op.
> Thanks for the help. Don
I hope this helps...
> On Aug 15, 2008, at 2:21 PM, Charles Steinman wrote:
>
>> --- 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;
>>> }
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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