Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSInvocation question




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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >NSInvocation question (From: Hank Heijink <email@hidden>)
 >Re: NSInvocation question (From: Nir Soffer <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.