• 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: NSUndoManager retain/release of arguments - ad infinitum
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSUndoManager retain/release of arguments - ad infinitum


  • Subject: Re: NSUndoManager retain/release of arguments - ad infinitum
  • From: John Bartleson <email@hidden>
  • Date: Thu, 13 Jan 2011 22:58:23 -0800

Graham: thanks for your comment and thanks for being patient with a relative n00b. Hopefully we can
nail this topic down in a post or two.


You are not required to verify it. (Though you may do so using the memory tracing tools). You only need to follow the rules, and understand that the undo manager also follows the rules. When everyone follows the rules, the need to verify and check ownership disappears - you can take it as read that correct memory management is performed. In other words you only need to concentrate on ensuring YOUR code follows the rules - the frameworks can be assumed to.

I'm sure you'd agree that when we're learning a new environment, references and documentation are only
part of the process. If we can't figure out the docs, and lacking an expert in the next cubicle to ask,
then writing a test app will usually quickly answer our question. This is where a legitimate need to
verify and check object ownership comes from.


You mentioned memory tracing tools. I'm familiar with Instruments, but I wasn't aware you could use it
to trace individual variables. Did you have a particular tool in mind?


So yes, that means that the undo manager does take ownership of the arguments, because it owns the invocations.

I'm glad to see this, because it's really the answer to my original question. Poking around a little, one finds
NSInvocation's retainArguments method, which is probably what NSUndoManager uses.


You've stated that I "only need to follow the rules." This left me to wonder which memory management rules
I had missed that would predict the above result. My day-to-day MM rules include the ususal: "If you create it
(alloc, new, copy, etc.) you own it," "You can take ownership with retain," "When you're finished with something
you own, you must release it," etc.


In addition we also learn special MM rules for useful framework classes, e.g. a collection will retain objects
passed to it. I don't, however, know any special rules pertaining to NSUndoManager and NSInvocation. So I re-read
Apple's "Memory Management Programming Guide." I honestly can't find anything in there that would be an obvious
rule pertaining to the current topic. Which rules are relevant here?



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSUndoManager retain/release of arguments - ad infinitum
      • From: "Gary L. Wade" <email@hidden>
    • Re: NSUndoManager retain/release of arguments - ad infinitum
      • From: Graham Cox <email@hidden>
References: 
 >Re: NSUndoManager retain/release of arguments - ad infinitum (From: steven Hooley <email@hidden>)
 >Re: NSUndoManager retain/release of arguments - ad infinitum (From: Graham Cox <email@hidden>)
 >Re: NSUndoManager retain/release of arguments - ad infinitum (From: John Bartleson <email@hidden>)
 >Re: NSUndoManager retain/release of arguments - ad infinitum (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Maintaining NSCursor outside of app window
  • Next by Date: Re: NSUndoManager retain/release of arguments - ad infinitum
  • Previous by thread: Re: NSUndoManager retain/release of arguments - ad infinitum
  • Next by thread: Re: NSUndoManager retain/release of arguments - ad infinitum
  • Index(es):
    • Date
    • Thread