• 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: "Paul Sanders" <email@hidden>
  • Date: Thu, 8 Jul 2010 13:55:50 +0100

>> 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.

>> Mike

> 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

That's what I'm currently doing - releasing the referenced object in an override of sendEvent.  The problem is that events don't always go through there (in a modal tracking loop, specifically) so I need handle that case too.  Why?  Well, it's too complicated to go into here but I actually play all kinds of games with event handling in order to emulate the Windows API, which has a rather different view of the world.  It's not my most favourite piece of code.  Strangely, if you post a mouse or keyboard event to the input queue, the event that is eventually delivered is a copy of the original, rather than the event you actually posted.  Why this should be I don't know but it makes life much harder for me.

So I shall ponder my options.  What I have works, but I have had one crash report from the field (just one) where my referenced object pointer was obviously stale so there must be a little loophole in there somewhere.  Thanks for the input guys, much appreciated.

Regards,

Paul Sanders.
_______________________________________________

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

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>)
 >Re: How to catch [NSEvent dealloc]? (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Sanity Check
  • Next by Date: Re: Sanity Check
  • Previous by thread: Re: How to catch [NSEvent dealloc]?
  • Next by thread: Sanity Check
  • Index(es):
    • Date
    • Thread