Re: MyDocument instance variables, dealloc problems
Re: MyDocument instance variables, dealloc problems
- Subject: Re: MyDocument instance variables, dealloc problems
- From: Andrew Madsen <email@hidden>
- Date: Sun, 12 Nov 2006 08:01:57 -0700
Thanks for the reply Mike.
I changed my setter method so that it releases the old value (I
should have known that!), but the problem persists. If I turn
NSZombie on, I can see that messages are being sent to the "old"
window in the second document. So I might have something like this:
For the first document, I have docWindow: <NSWindow: 0x39a5b0>.
Then when I close that window and create a new document, I get:
Exception raised during posting of notification. Ignored.
exception: *** Selector 'respondsToSelector:' sent to dealloced
instance 0x39a5b0 of class NSWindow.
Break at '-[_NSZombie respondsToSelector:]' to debug.
If I break on that, I see that it is occurring where my NSLog
(@"docWindow: %@", docWindow); statement is. However, the statement
also produces something like:
docWindow: <NSWindow: 0xd930700>
This is all occurring my windowControllerDidLoadNib: method, so in a
regular build (ie. without NSZombie on), the errors/crashes prevent
new document windows from opening. However, with NSZombie on, new
document windows do open.
It seems like windows for closed documents get deallocated, which
seems right. However, for some reason, when subsequent documents are
opened/created and a new document window is created, something is
trying to continue to send messages to the windows of previous
documents (I get multiple NSZombie exceptions for the third and
subsequent documents). It all stops if I never set possibleColumns.
Any ideas?
Thanks,
Andrew
On Nov 12, 2006, at 2:35 AM, Mike Abdullah wrote:
eek! That is a very bad accessor method :)
You are retaining the new value, but never releasing the old.
Instead, try something like:
- (void)setPossibleColumns:(NSDictionary *)value
{
if (value == possibleColumns)
return;
[possibleColumns release];
possibleColumns = [value retain];
}
I'm not sure if that'll entirely solve your problem, but it's a start!
Mike.
_______________________________________________
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