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 PROTECTED]



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to