Hi All,

I'm trying to program a simple timer app: you enter a number of seconds, and it updates a text field every second with the number of secs remaining. The problem is that I'm not able to do anything with the UI while this is going on. Here's my code:

- (IBAction)startTimer:(id)sender
{
   [startButton setState:NSOffState];
int timeInSeconds = [((NSNumber *)[inTextField objectValue]) intValue]; while (timeInSeconds > 0) { [outTextField setStringValue:[NSString stringWithFormat:@"%d more second(s) to go", timeInSeconds]]; sleep(1);
       timeInSeconds--;
   }
[outTextField setStringValue:@"Finished timing"];
   NSBeep();
}

What's happening is that if I enter a number and then press 'start', 'start' stays in the 'pressed' position until the loop finishes, after which it returns to the normal position. My guess is that this is stopping any other UI events from occurring. This would also explain why I'm able to log a message each time the loop iterates.

But I'm still not sure why the button is staying pressed. Thoughts, anyone?

Daniel
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to