• 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: How to catch [NSEvent dealloc]?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to catch [NSEvent dealloc]?


  • Subject: Re: How to catch [NSEvent dealloc]?
  • From: Ken Thomases <email@hidden>
  • Date: Thu, 8 Jul 2010 00:35:59 -0500

On Jul 8, 2010, at 12:03 AM, Michael Ash wrote:

> On Wed, Jul 7, 2010 at 6:34 PM, Paul Sanders <email@hidden> wrote:
>>> 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.
>>
>> Sadly (and possibly mistakenly), I'm still supporting 10.4.  I think I need
>> to review this policy!  Good idea though.
>
> In that case I'd guess you might want to use method swizzling on
> -[NSEvent dealloc]:
>
> http://www.cocoadev.com/index.pl?MethodSwizzling
>
> Beware that swizzling is a powerful and dangerous technique, and you
> want to code your override with the utmost caution, but it's a great
> way to intercept methods like this.

Since the event is application-defined, any handler will, of course, also be application-defined.  Can't you handle this in the handler?  Or, alternatively, in an override of -[NSApplication sendEvent:]?

Regards,
Ken

_______________________________________________

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: How to catch [NSEvent dealloc]?
      • From: "Paul Sanders" <email@hidden>
References: 
 >How to catch [NSEvent dealloc]? (From: "Paul Sanders" <email@hidden>)
 >Re: How to catch [NSEvent dealloc]? (From: Michael Ash <email@hidden>)
 >Re: How to catch [NSEvent dealloc]? (From: "Paul Sanders" <email@hidden>)
 >Re: How to catch [NSEvent dealloc]? (From: Michael Ash <email@hidden>)

  • Prev by Date: Re: How to catch [NSEvent dealloc]?
  • Next by Date: setting focus on NSSearchField in status bar menu item
  • Previous by thread: Re: How to catch [NSEvent dealloc]?
  • Next by thread: Re: How to catch [NSEvent dealloc]?
  • Index(es):
    • Date
    • Thread