Re: How to catch [NSEvent dealloc]?
Re: How to catch [NSEvent dealloc]?
- Subject: Re: How to catch [NSEvent dealloc]?
- From: Michael Ash <email@hidden>
- Date: Wed, 7 Jul 2010 17:49:54 -0400
On Wed, Jul 7, 2010 at 3:53 PM, Paul Sanders <email@hidden> wrote:
> I have a problem. I need to know when an NSApplicationDefined NSEvent is deallocated, because it contains a reference to an object in data1 and I want to release that object at that time. Problem is, you can't subclass NSEvent because there are no public initialisers. Short of swizzling [NSEvent dealloc] (erk!) does anyone have an idea about how I might be able to catch an NSEvent object at the point of deallocation?
If you can require 10.6 (or iOS 4, maybe?) then you can use the new
associated object API. Use objc_setAssociatedObject to attach your
object to the NSEvent object, and the runtime will automatically take
care of destroying it for you when the NSEvent is destroyed.
Mike
_______________________________________________
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