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 21:10:30 -0700
On Fri, Jun 27, 2008 at 8:59 PM, Shawn Erickson <email@hidden> wrote:
> 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:
>
> Look at using NSTimer to trigger a callback that will allow you to
> update UI as needed.
As Stephen noted... you need record the start time (or record the end
time) then check current time (look at NSDate) to ensure you count out
the requested amount of time. Also you should fire your timer every
0.75 of seconds (or so) to ensure your UI update is consistent/smooth.
Firing every second may cause your timer to fire a little after 1
second later so your UI could skip from say 50s to 52s.
-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