Re: NSApplication Quit bug; Another Form of it. Learning Cocoa sample shows related bug.
Re: NSApplication Quit bug; Another Form of it. Learning Cocoa sample shows related bug.
- Subject: Re: NSApplication Quit bug; Another Form of it. Learning Cocoa sample shows related bug.
- From: tyler <email@hidden>
- Date: Tue, 17 Jul 2001 17:30:49 -0700
On Tuesday, July 17, 2001, at 04:13 PM, David P. Henderson wrote:
On Tuesday, July 17, 2001, at 06:49 , tyler wrote:
I do think that the code that reanimates the objects in the NIB should
dispose of them (?)
You CREATED those objects. You are responsible for disposing of all top
level objects you create in a nib file if it is important to do so ie,
it will leak significant memory overtime. This can be as simple as
checking the Release When Closed box for a window. When you load a nib,
you cause those objects in it to be unarchived for use; therefore,
releasing them is your problem.
Ok Dave. I'm basically with you.
The only problem is that I did not actually create those objects. I
didn't load any nib file at all.
I used the default NSApplicationMain() routine that Project Builder puts
into the defaul main.m file.
I'm just doing one of the basic tutorials in the Learning Cocoa book
which is presumably written for programmers new to Cocoa and mac os x.
It turns out that the loading of the main nib file probably happens
inside NSApplicationMain() (I don't have the source to
NSApplicationMain(), but I found the documentation in NSApplication
which shows a sample of what that routine may do).
Even if that code sample in the documentation for NSApplicationMain(),
it is not immediately apparent HOW I would release objects from the Nib
file (ok, windows I can set in IB, got that, thanks); I do not have a
reference (variable) to them anywhere that I am aware of. How would I
send them the release message? Presumably I can get them somehow, but
for a starting Cocoa programmer that may be getting a little advanced
don't you think? (If you know the answer on how to dispose of a
controller that has been instantiated in the main Nib file, I'd like to
know, thanks!).
So, I guess that I did create those objects, but for a novice developer
it sure seems like they were automagically created by the framework and
should be automagically disposed of when the application quits.
So, if this is indeed something that needs to be done, then there is
some documentation of this fact that needs to happen. There are two
places that come to mind: 1) In the Learning Cocoa book would be a good
place to have this since this is many cocoa programmers first learning
location; 2) in the documentation for NSApplicationMain where it shows
the loading of the nib file.
In addition, the sample I referenced (Notification sample ch 8) has code
in a MyController dealloc method to clean up after itself THAT IS NEVER
CALLED as the sample is written (with the current AppKit).
So, either the sample needs fixing, or the framework does. I'm not
currently qualified to put forth an opinion on which needs fixing, I'm
just trying to point out that something isn't right here and asking
someone who: a) knows more about this framework than I do; and b) has
access to the source(s) to change these things, to please fix one or
the other.
My only goal is to make a the development experience, software
functionality, and user experience as good as possible so that the OS
and Developers for it all prosper.
peace,
Tyler