Re: Proper Way to "Unload" a Loaded Nib w/Bindings [Solved, Maybe]
Re: Proper Way to "Unload" a Loaded Nib w/Bindings [Solved, Maybe]
- Subject: Re: Proper Way to "Unload" a Loaded Nib w/Bindings [Solved, Maybe]
- From: Keary Suska <email@hidden>
- Date: Tue, 27 Mar 2007 14:55:19 -0600
- Thread-topic: Proper Way to "Unload" a Loaded Nib w/Bindings [Solved, Maybe]
on 3/27/07 2:00 PM, email@hidden purportedly said:
>> The problem is that when I release the top level objects, my app crashes. My
>> research seems to show that this is because of an NSWindow's
>> initialFirstResponder outlet being set.
>
> My guess is that you are either overreleasing an object, or you have a weak
> reference an object that has already been released.
>
> But this isn't a nib problem. This is standard Cocoa memory management and
> you'd have the same problem wether the objects were created from a nib or
> programmatically.
The problem was not what I originally thought, but was because I was using
NSWindow's -makeFirstResponder. If I call it with nil before I release the
top level objects, the crash stops. This would indicate an issue with the
nib, from my point of view, and a bug to boot. The nib/window should be
responsible for the first responder, since it is a subview, and one that I
am neither creating nor releasing (always an NSTextField in the window).
Fortunately, using -makeFirstResponder was just a hold-over from a previous
implementation that I don't need to use, so I abandoned its use completely
and have remained crash-free.
>> The docs warn that all outlets
>> should be set to nil for all objects in the nib, but don't mention how this
>> may be done when the outlets aren't known by the nib owner.
>
> Again, this is responsibility of the individual objects, not really the nib's
> owner. A window that is being released should not be using its initial first
> responder. If it is, something's wrong -- but this should have nothing to do
> with the fact the objects were created by a nib.
I should have been more specific--I was referring to the Resource
Programming Guide, which states:
"After releasing the top-level objects, it is a good idea to clear any
outlets pointing to objects in the nib file by setting them to nil. You
should clear outlets associated with all of the nib fileĀ¹s objects, not just
the top-level objects."
My first assumption was that it meant in-nib outlets, but a closer reading
could indicate that they mean programmatically-created outlets to nib
objects from outside of the nib itself. I assume this is possible, though I
have never done it or read about it.
Since I don't seem to be having any problems, perhaps I shouldn't worry
about it.
> I think regular bindings should take care of themselves, but be careful of any
> observers that you've manually connected. Neither the observer or observee are
> retained. I typically disconnect my observers in the dealloc method.
Thanks,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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