• 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 does NOT repeat, why ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTimer does NOT repeat, why ?


  • Subject: Re: NSTimer does NOT repeat, why ?
  • From: Thomas Davie <email@hidden>
  • Date: Thu, 18 Sep 2008 11:33:07 +0200


On 18 Sep 2008, at 11:18, Florian Soenens wrote:

Hi list,

anyone knows why in this simple piece of code, the method testTimer is only called once and not every 2 seconds?

Thanks in advance;
Florian.

#import "Controller.h"

@implementation Controller

-(void) awakeFromNib
{
NSLog(@"Creating NSTimer");
timer = [[NSTimer timerWithTimeInterval:2.0 target:self selector:@selector(testTimer) userInfo:nil repeats:YES] retain];
[timer fire];
}


-(void) testTimer
{
	NSLog(@"Test");
}

The timer only fires once, because you are only telling it to fire once. You should instead be scheduling it.


Bob
_______________________________________________

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: NSTimer does NOT repeat, why ?
      • From: Florian Soenens <email@hidden>
References: 
 >NSTimer does NOT repeat, why ? (From: Florian Soenens <email@hidden>)

  • Prev by Date: Re: NSTimer does NOT repeat, why ?
  • Next by Date: Re: NSTimer does NOT repeat, why ?
  • Previous by thread: Re: NSTimer does NOT repeat, why ?
  • Next by thread: Re: NSTimer does NOT repeat, why ?
  • Index(es):
    • Date
    • Thread