NSTimer troubles

  • I tried the line of code:
    [[NSRunLoop currentRunLoop] addTimer:[NSTimer timerWithTimeInterval:1
    target:self selector:@selector(stopIt:) userInfo:nil repeats:NO]
    forMode:@"Fubar"];

    Why does it not work?

    Daniel Staudigel

    ---------------

    How to fly:  Find a nice big cliff, jump off, and miss the ground!  Easy
    enough!
  • Your timer is not firing because the run loop is not ever getting run
    for the "Fubar" mode.  For run loop input sources to be processed the
    run loop needs to be run in the mode that those sources are scheduled
    for.  So, you might try something more like this

    [[NSRunLoop currentRunLoop] addTimer:[NSTime timerWithTimeInterval:1
    target:self selector:@selector(stopIt:) userInfo:nil repeats:NO]
    forMode:NSDefaultRunLoopMode];

    Another way to do this would be -

    [NSTimer scheduledTimerWithTimeInterval:1 target:self
    selector:@selector(stopIt:) userInfo:nil repeats:NO];

    Hope this helps.

    ryan

    --
    Ryan Dingman
    <ryan...>

    On Monday, May 14, 2001, at 09:25 PM, Daniel Staudigel wrote:

    > I tried the line of code:
    > [[NSRunLoop currentRunLoop] addTimer:[NSTimer timerWithTimeInterval:1
    > target:self selector:@selector(stopIt:) userInfo:nil repeats:NO]
    > forMode:@"Fubar"];
    >
    > Why does it not work?
    >
    > Daniel Staudigel
    >
    > ---------------
    >
    > How to fly:  Find a nice big cliff, jump off, and miss the ground!
    > Easy enough!
    > _______________________________________________
    > MacOSX-dev mailing list
    > <MacOSX-dev...>
    > http://www.omnigroup.com/mailman/listinfo/macosx-dev
previous month may 2001 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today