• 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: Nir Soffer <email@hidden>
  • Date: Mon, 25 Feb 2008 22:30:42 +0200


On Feb 21, 2008, at 18:22, Hank Heijink wrote:

I have a document-based application, and my NSDocument subclass runs an experiment which amounts to invoking NSInvocations based on certain conditions. These NSInvocations retain their arguments, and the target of the NSInvocation is the NSDocument subclass. I need to record these invocations as well, so I made a class MVAction as follows:

@interface MVAction : NSObject <NSCoding> {
	NSInvocation *action;
	double invocationTime;
	NSString *type;
	NSArray *arguments;
}

The type is a string representation of the selector used in the NSInvocation and the arguments are the arguments of the NSInvocation. I did it like this because you can't encode an NSInvocation, and I don't need the actual invocation anyway. My document has an instance variable NSMutableArray *actions in which these MVActions are stored.

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.

Another fix - when your document is closed, release the array holding the MVActions, which retain the invocation. This will break the retain cycle and allow your document to be released.



Best Regards,

Nir Soffer

_______________________________________________

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: Hank Heijink <email@hidden>
References: 
 >NSInvocation question (From: Hank Heijink <email@hidden>)

  • Prev by Date: Resizable Text Cell in NSTableView
  • Next by Date: Re: NSInvocation question
  • Previous by thread: Re: NSInvocation question
  • Next by thread: Re: NSInvocation question
  • Index(es):
    • Date
    • Thread