• 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: NSTimer fires after invalidated - why?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTimer fires after invalidated - why?


  • Subject: Re: NSTimer fires after invalidated - why?
  • From: Cameron Hayne <email@hidden>
  • Date: Thu, 23 Mar 2006 12:04:34 -0500

On 23-Mar-06, at 2:22 AM, Andreas Mayer wrote:

Just for the record - there's a way to even avoid explicitly allocating a timer:

[NSObject cancelPreviousPerformRequestsWithTarget:m_drawer selector:@selector(close:) object:self];
[m_drawer performSelector:@selector(close:) withObject:self afterDelay:5.0];

I have found this mechanism quite useful in past projects and have packaged it into the following utility method:


// The following is a utility routine that is used for postponing a selector
// until after some activity is finished.
// It is designed to be repeatedly called while the activity is ongoing
// and it will result in the selector being invoked exactly once
// after the activity has finished.
+ (void)performOnce:(SEL)aSelector
withTarget:(id)aTarget
withObject:(id)anArgument
afterDelay:(NSTimeInterval)delay
{
// cancel any pending requests of this type
[NSObject cancelPreviousPerformRequestsWithTarget: aTarget
selector: aSelector
object: anArgument];
// schedule the request
[aTarget performSelector: aSelector
withObject: anArgument
afterDelay: delay];
}



-- Cameron Hayne email@hidden


_______________________________________________ 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: NSTimer fires after invalidated - why?
      • From: John Stiles <email@hidden>
References: 
 >Re: NSTimer fires after invalidated - why? (From: Walt Horat <email@hidden>)
 >Re: NSTimer fires after invalidated - why? (From: Andreas Mayer <email@hidden>)

  • Prev by Date: Re: Sending mail
  • Next by Date: Re: NSTimer fires after invalidated - why?
  • Previous by thread: Re: NSTimer fires after invalidated - why?
  • Next by thread: Re: NSTimer fires after invalidated - why?
  • Index(es):
    • Date
    • Thread