|
From: | David Chisnall |
Subject: | When should an NSDocument stop being an NSWindow's delegate? |
Date: | Sun, 25 Oct 2009 17:06:01 +0000 |
This usually doesn't make much difference, because the window controller takes ownership, and then sets the _window ivar in the document to nil, and so the release message is sent to nil instead of the window.
The problem comes if you follow the common pattern of setting the document (the file's owner) as the window's delegate in the nib. In order for this not to crash when the window sends a respondsToSelector: message to the delegate while closing, the document must remove itself as the delegate before it exists. This would be easy, except that the window controller has stolen the window and the window controller itself has removed itself from the array of window controllers by the time -dealloc is called, so there is no way for an NSDocument subclass to get the window in -dealloc and do this removal...
David -- Sent from my Apple II
[Prev in Thread] | Current Thread | [Next in Thread] |