Undo prepareWithInvocationTarget: retain/release question
Undo prepareWithInvocationTarget: retain/release question
- Subject: Undo prepareWithInvocationTarget: retain/release question
- From: Keith Blount <email@hidden>
- Date: Tue, 8 Mar 2005 16:27:47 -0800 (PST)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Hello,
In testing the undo/redo implementations in my app, I
have found that I am getting a crash when doing
something like the following:
[[[self undoManager] prepareWithInvocationTarget:self]
undoRemoveView:aView];
...
- (void)undoRemoveView:(NSView *)aView
{
[self addSubview:aView];
[aView release];
}
The crash is caused by releasing aView, as it is
apparently crashing with the same object being
released in an autorelease pool. This has had me
stumped, as I know I have to release an object after
adding it as a subview.
I am guessing this is to do with how the undo manager
works. Am I right in assuming that the undo manager
retains an object when it is used in a call to
prepareWithInvocationTarget:, and then autoreleased
after undo/redo has been called with that
target/method? In which case, I don't need to release
the object myself as it is done automatically...
Maybe I've missed something obvious in the undo
architecture intro or NSUndoManager description in the
docs, but I'd be very grateful if somebody could clear
this up for me.
Many thanks,
Keith
__________________________________
Celebrate Yahoo!'s 10th Birthday!
Yahoo! Netrospective: 100 Moments of the Web
http://birthday.yahoo.com/netrospective/
_______________________________________________
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