• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Undomanager and deallocate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Undomanager and deallocate
      • From: "Mark's Studio" <email@hidden>
References: 
 >Undomanager and deallocate (From: "Mark's Studio" <email@hidden>)

  • Prev by Date: Undomanager and deallocate
  • Next by Date: Re: Undomanager and deallocate
  • Previous by thread: Undomanager and deallocate
  • Next by thread: Re: Undomanager and deallocate
  • Index(es):
    • Date
    • Thread