Re: Undomanager and deallocate
Re: Undomanager and deallocate
- Subject: Re: Undomanager and deallocate
- From: David Remahl <email@hidden>
- Date: Tue, 30 Oct 2001 10:20:31 +0100
>
What is the correct way of doing this, if any?
>
>
[[self undoManager] registerUndoWithTarget:self
>
selector:@selector(undoMethod:) object:[myObject copy]];
>
>
[[self undoManager] registerUndoWithTarget:self
>
selector:@selector(undoMethod:) object:[[myObject copy] autorelease]];
>
>
will the undoManager deallocate myObject when it's finish with it.
>
i have only tried [myObject copy] and it works without any errors, so is
>
that ok?
The second way is the correct one, or the object created by the copy call
will be lost. What you either copy or retain, you also nead to release.
Doing it the first way would not create an error, but the object would leak.
/ david