Re: while loop with sleep(): logging works, but not UI events
Re: while loop with sleep(): logging works, but not UI events
- Subject: Re: while loop with sleep(): logging works, but not UI events
- From: "Shawn Erickson" <email@hidden>
- Date: Fri, 27 Jun 2008 20:59:57 -0700
On Fri, Jun 27, 2008 at 8:55 PM, Daniel Richman
<email@hidden> wrote:
> 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:
Don't loop like this. Think about what is taking place... you are
looping never allowing your main thread to do anything else. Your loop
is not returning out to the normal runloop which handles user input
and drives your UI.
Look at using NSTimer to trigger a callback that will allow you to
update UI as needed.
-Shawn
_______________________________________________
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