• 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
Invalidate non-repeating NSTimer after fired?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Invalidate non-repeating NSTimer after fired?


  • Subject: Invalidate non-repeating NSTimer after fired?
  • From: Trygve Inda <email@hidden>
  • Date: Fri, 03 Aug 2012 13:19:22 -0700
  • Thread-topic: Invalidate non-repeating NSTimer after fired?

NSTimer* myTimer = [NSTimer scheduledTimerWithTimeInterval:60 target:self
selector:@selector(wantsUpdate:) userInfo:nil repeats:NO]

Sometime after it fires (and occasionally before), I call

if ( myTimer )
{
   [myTimer invalidate];
   [myTimer release];
   myTimer = nil;
}


Should I really be doing:

if ( myTimer )
{
    if ([myTimer isValid])
         [myTimer invalidate];

   [myTimer release];
   myTimer = nil;
}



I am doing it the first way without trouble... At least I think it is ok.
The docs say non-repeating timers are invalidated after they fire.

Which way is better?

Comments?




_______________________________________________

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: Invalidate non-repeating NSTimer after fired?
      • From: Charlie Dickman <email@hidden>
  • Prev by Date: NSTimer fireDate on invalidated timer not working according to docs
  • Next by Date: Re: +underPageBackgroundColor
  • Previous by thread: NSTimer fireDate on invalidated timer not working according to docs
  • Next by thread: Re: Invalidate non-repeating NSTimer after fired?
  • Index(es):
    • Date
    • Thread