Re: NSWindowController retain counts, chapter 2
Re: NSWindowController retain counts, chapter 2
- Subject: Re: NSWindowController retain counts, chapter 2
- From: Graham Cox <email@hidden>
- Date: Tue, 7 Oct 2008 13:13:22 +1100
On 7 Oct 2008, at 11:38 am, James Walker wrote:
NSWindowController has a perfectly good member variable called
'window' that supplies the window in question, and is returned by
the -window method (provided you remembered to hook it up in IB of
course).
NSWindowController.h does not say that it has a member variable
named window, it says that there is a private member variable named
_window.
Being private means just that. However, if you have an
NSWindowController in IB, you'll see an outlet named 'window' (not
_window). This should be wired up to the window object in the nib. How
it's implemented is irrelevant - don't use or access _window. Note:
peeking at the headers of Cocoa objects is almost never necessary.
I can accept that looking at retain counts may just be confusing me,
but "just following the rules" hasn't sufficed.
Well, what is it in "the rules" that you are not understanding?
How do you know the window isn't being deallocated? Examining
retain counts is not going to tell you whether it is or not. The
only way would be to subclass it and log the -dealloc method.
That's exactly what I did. The dealloc method was not getting
called before I added the workaround. Well, the initial symptom was
that I got an access violation because a custom view was asked to
draw after the window had been closed and the window controller had
been destroyed. In the course of debugging that, I subclassed the
window.
I'd suggest it would be more fruitful to chase down the actual bug
rather than one that appears to be related but might be just a red
herring.
If a view is being asked to draw but its window has gone away, then
something's very, very off somewhere. Normally views are drawn by
their windows, so how can such a situation arise? If you can answer
that question you've probably found the problem. Is some other object
retaining the view? Why? Are you drawing outside the usual update
event cycle mechanism? Why?
Graham
_______________________________________________
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