• 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: NSMatrix mouse puzzle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMatrix mouse puzzle


  • Subject: Re: NSMatrix mouse puzzle
  • From: Graham Cox <email@hidden>
  • Date: Thu, 4 Sep 2008 14:52:08 +1000


On 4 Sep 2008, at 2:40 pm, D.K. Johnston wrote:

	// wait 10 seconds
	NSUInteger i = 0, resume = time( nil ) + 10;
	while( i < resume )
		index = time( nil );



Don't do this!

This is not a good way to wait for a period of time, even if waiting for a period of time were a good way to do what you want (which it isn't). All this does is chew up CPU time - events will still be captured and queued while this is running, so when it ends, they just get processed and passed to the now enabled control. Also, as posted the above code never terminates - i is never changed.

What's to say your "data display" always takes 10 seconds anyway? Depends on the data, the machine you're running on, etc, etc... time delay loops are what a first-timer using BASIC uses - real programmers never do this.

Disable the matrix at the start of data load. When the data load finishes, signal that fact to some object that re-enables the control. Load the data asynchronously (using a thread or timer-driven loop).

hth,

Graham

_______________________________________________

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: NSMatrix mouse puzzle
      • From: "D.K. Johnston" <email@hidden>
References: 
 >NSMatrix mouse puzzle (From: "D.K. Johnston" <email@hidden>)

  • Prev by Date: NSMatrix mouse puzzle
  • Next by Date: Re: NSMatrix mouse puzzle
  • Previous by thread: NSMatrix mouse puzzle
  • Next by thread: Re: NSMatrix mouse puzzle
  • Index(es):
    • Date
    • Thread