Note that there are some explanatory texts on larger screens.

plurals
  1. POStop pinwheel of death in infinite loop Objective C
    primarykey
    data
    text
    <p>I am writing a simple timer program for myself in objective c for my mac. The timer counts down properly, but I get the spinning pinwheel of death. How can I make the pinwheel go away? I think its because I have an infinite loop but there must be someway to bypass it.</p> <p>I have an IBAction that triggered on a button click (the button is start). And from there, it calls another function that does the work.</p> <p>Here is my IBAction:</p> <pre><code>- (IBAction)timerStart:(id)sender { self.timerDidPause = NO; [self timerRunning]; } </code></pre> <p>And here is timerRunning:</p> <pre><code>- (void)timerRunning { for (;;) { usleep(1000000); if (self.timerDidPause == YES) { } else { if (self.seconds == 0) { if (self.minutes == 0) { [self timerDone]; break; } else { self.seconds = 59; self.minutes = self.minutes - 1; [self formatTimerLabel:self.hours :self.minutes :self.seconds]; } } else { self.seconds = self.seconds - 1; [self formatTimerLabel:self.hours :self.minutes :self.seconds]; } } } } </code></pre> <p>In this function, the function formatTimerLabel is called so here is that:</p> <pre><code>- (void)formatTimerLabel:(int)hours :(int)minutes :(int)seconds { NSString *minuteString = [[NSString alloc] init]; NSString *secondString = [[NSString alloc] init]; if (minutes &lt; 10) { minuteString = [NSString stringWithFormat:@"0%d", minutes]; } else { minuteString = [NSString stringWithFormat:@"%d", minutes]; } if (seconds &lt; 10) { secondString = [NSString stringWithFormat:@"0%d", seconds]; } else { secondString = [NSString stringWithFormat:@"%d", seconds]; } [self.timerLabel setStringValue:[NSString stringWithFormat:@"%d:%@:%@", hours, minuteString, secondString]]; [self.timerLabel display]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload