• 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: while loop with sleep(): logging works, but not UI events
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: while loop with sleep(): logging works, but not UI events
      • From: "Shawn Erickson" <email@hidden>
References: 
 >while loop with sleep(): logging works, but not UI events (From: Daniel Richman <email@hidden>)

  • Prev by Date: while loop with sleep(): logging works, but not UI events
  • Next by Date: NSPopupButton Bindings-Related Issue
  • Previous by thread: while loop with sleep(): logging works, but not UI events
  • Next by thread: Re: while loop with sleep(): logging works, but not UI events
  • Index(es):
    • Date
    • Thread