• 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: Retain or copy NSEvents?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Retain or copy NSEvents?


  • Subject: Re: Retain or copy NSEvents?
  • From: Ricky Sharp <email@hidden>
  • Date: Sat, 15 Dec 2007 09:23:57 -0600


On Dec 15, 2007, at 7:50 AM, David Hoerl wrote:

I have some classic drag and drop code, where I save the mouse down event, and then later provide this event to dragImage when the drag and drop begins.

My original code simply retained the mouseDown event. A month or so ago I was reading some Apple document that said the system sometimes "reuses" an event, and thus the proper way to retain an event is to make a copy of it. I modified my code and made a simple note that Apple advised doing this. [I also recall going to the online NSEvent document and making a comment that this fact should be in the NSEvent documentation, and sited the reference.]

Of course, now that I was asked for a reference on this, I cannot for the life of me find it. I tried all the Event and NSEvent documentation, NSRunLoop, and Drag and Drop.

Does anyone out there recall where this is documented? If so please speak up! Thanks,


In the book "Cocoa Programming" (Anguish, Buck, Yacktman) Chapter 8, in the "What is a Responder?" section (page 192):

"The NSEvent passed to each event-processing method is only valid within that method's implementation. The Cocoa frameworks reserve the right to reuse existingNSEvent instances or otherwise tamper with their contents. To preserve the information in an NSEvent instance, copy it or store the information in a separate data structure. Simply retaining the NSEvent instance for later use is not sufficient."

As to what Apple document (if any) that this was derived from, I do not know.

___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________

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: 
 >Retain or copy NSEvents? (From: David Hoerl <email@hidden>)

  • Prev by Date: Bill Abt is out of the office for the holidays.
  • Next by Date: Re: NSArrayController delete objects once removed
  • Previous by thread: Retain or copy NSEvents?
  • Next by thread: Bill Abt is out of the office for the holidays.
  • Index(es):
    • Date
    • Thread