Re: Do I need to release IBOutlets in dealloc?
Re: Do I need to release IBOutlets in dealloc?
- Subject: Re: Do I need to release IBOutlets in dealloc?
- From: Fritz Anderson <email@hidden>
- Date: Thu, 18 Aug 2005 11:13:05 -0500
On 18 Aug 2005, at 8:57 AM, Christopher Hickman wrote:
I have an NSApplication subclass to which I've added an IBOutlet so
I can
connect an interface element in IB to my NSApp instance for easy
messaging.
I'm using IB to connect my outlet to the control. I know your dealloc
method usually needs to release the ivars you've added to your
class, but I
wasn't sure if IBOutlet ivars were special-case or not. Do I need
to send
my IBOutlet ivar a release in my dealloc to prevent memory leaks?
1. Don't start new threads by replying to old ones. It screws up the
threading display for other people.
2. Ordinarily, you wouldn't service user-interface events in an
application class, but would (in a very simple application) have an
application delegate which is an instance of a custom subclass of
NSObject. It would have the outlets and actions necessary to run the
human interface.
3. The File's Owner is responsible for releasing only the top-level
(icon-in-NIB-window) objects in a NIB. The item in your IBOutlet is
presumably not naked in the NIB, but is embedded in the view
hierarchy of a window in the NIB. The File's Owner (the application)
is responsible for disposing of the window, which will dispose of its
contents.
4. But in this case, the File's Owner is the application object,
which I don't think gets deallocated at all -- when it's time for it
to die, the application dies, and its memory is returned to the
system en masse, with no need to groom the contents. Objective-C does
not guarantee C++-like ctor/dtor semantics.
-- F
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden