• 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: NSEvent isEqual
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSEvent isEqual


  • Subject: Re: NSEvent isEqual
  • From: Matt Gough <email@hidden>
  • Date: Wed, 3 May 2006 23:41:05 +0100


On 3 May 2006, at 23:24, John Stiles wrote:

If the pointer is the same, then by definition its contents must be the same, right?

Yes and no. Consider this somewhat simple and contrived example:

static NSEvent* eventThatTriggeredUs;

void setup(NSEvent* anEvent)
{
eventThatTriggeredUs = anEvent;
}


void someTimeLater(NSEvent* anEvent) { if (eventThatTriggeredUs == anEvent) { // Must be the same event so we have to do our stuff

// Wrong - Without retaining in setup, anEvent might have been released
// in the meantime and been replaced by an entirely new event at the same address that is
// not supposed to cause us to end up in here.
}
}


You should always retain (eventThatTriggeredUs) in these cases to avoid such pitfalls.

Matt Gough



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSEvent isEqual
      • From: John Stiles <email@hidden>
References: 
 >NSEvent isEqual (From: Ken Victor <email@hidden>)
 >Re: NSEvent isEqual (From: Ondra Cada <email@hidden>)
 >Re: NSEvent isEqual (From: Ken Victor <email@hidden>)
 >Re: NSEvent isEqual (From: John Stiles <email@hidden>)

  • Prev by Date: Re: NSEvent isEqual
  • Next by Date: Re: NSEvent isEqual
  • Previous by thread: Re: NSEvent isEqual
  • Next by thread: Re: NSEvent isEqual
  • Index(es):
    • Date
    • Thread