• 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: user-stoppable program
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: user-stoppable program


  • Subject: Re: user-stoppable program
  • From: email@hidden
  • Date: Fri, 26 May 2006 08:24:10 +0200 (CEST)
  • Importance: Normal

> Indeed. An alternative option would be to replace the while() with an
> if(), and then use an NSTimer to repeatedly call the "worker" method.
> That would avoid blocking the run loop.

 > and then use an NSTimer to repeatedly call the "worker" method.
>That would avoid blocking the run loop.

  I tried the code below ; the timer does its job, but the problem is that
clicking the
"Stop It all" button does not stop the process. What am I doing wrong ?

In MyDocument.h :

-(IBAction) goForward /*does one iteration of the loop  */
-(IBAction) goOnAndOn /*iterates the loop until the user stops the process */

In MyDocument.m :

-(IBAction) goOnAndOn : (id) sender
{
   NSTimer* timer;
    if ([StopItAllButton state]==NSOffState) {
        NSLog(@"Starting");
        timer = [[NSTimer scheduledTimerWithTimeInterval:1.0
                                         target:self
                                       selector:@selector(goForward:)
                                       userInfo:nil
                                        repeats:YES] retain];
    } else {
        NSLog(@"Stopping");


        [timer invalidate];
        [timer release];
    }

}



                                                        Ewan


 _______________________________________________
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: user-stoppable program
      • From: Ole Voss <email@hidden>
References: 
 >user-stoppable program (From: email@hidden)
 >Re: user-stoppable program (From: "I. Savant" <email@hidden>)
 >Re: user-stoppable program (From: email@hidden)
 >Re: user-stoppable program (From: Cameron Hayne <email@hidden>)
 >Re: user-stoppable program (From: Sherm Pendley <email@hidden>)

  • Prev by Date: NSOutlineView Drag And Drop NSTreeController
  • Next by Date: [Q] which arrives earlier? applicationShouldTerminate or applicationWillTerminate
  • Previous by thread: Re: user-stoppable program
  • Next by thread: Re: user-stoppable program
  • Index(es):
    • Date
    • Thread