• 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: NSInvocation question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSInvocation question


  • Subject: Re: NSInvocation question
  • From: Hank Heijink <email@hidden>
  • Date: Thu, 21 Feb 2008 23:00:59 -0500


On Feb 21, 2008, at 7:42 PM, Nir Soffer wrote:

The problem I have is this: when I close my document, it isn't deallocated. If the invocations don't retain their arguments, that problem is gone, but I do need to retain them. What's a good way to solve this? I could release the NSInvocation *action when I put an MVAction in the array, but I wonder if there's a better method.


You have a retain cycle - the document retain the array which retain the invocation, which retain the document.

Ah. I didn't realize that an NSInvocation retains not only its arguments, but also its target (the document only occurs as target, never as argument). The documentation doesn't mention this, as far as I can tell.


If you save the target, selector and arguments, you can invoke the selector without NSInvocation. Don't retain the target.

I made NSInvocations because timing is critical and I didn't want to spend the time constructing the call when it needs to be invoked. I haven't profiled the difference yet though, so maybe the tradeof isn't bad. I'll give it a whirl.


Thanks!

Hank Heijink
email@hidden



_______________________________________________

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: NSInvocation question
      • From: Chris Suter <email@hidden>
References: 
 >NSInvocation question (From: Hank Heijink <email@hidden>)
 >Re: NSInvocation question (From: Nir Soffer <email@hidden>)

  • Prev by Date: Bindings problem
  • Next by Date: Re: [self setLayer:] in initWithFrame:
  • Previous by thread: Re: NSInvocation question
  • Next by thread: Re: NSInvocation question
  • Index(es):
    • Date
    • Thread