• 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: [Q] how to tell when drawing is done?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Q] how to tell when drawing is done?


  • Subject: Re: [Q] how to tell when drawing is done?
  • From: Sherm Pendley <email@hidden>
  • Date: Wed, 4 Feb 2004 13:36:15 -0500

On Feb 4, 2004, at 1:03 PM, Steve Christensen wrote:

I have a NSWindowController managing a window that contains a NSTabView that contains NSTableViews as subviews. When I switch to a new tab (usually the first time), it's possible that the data source supplying the table could take a little while to get its data in order. I'd like to display a spinning NSProgressIndicator while all this is going on until the views finish drawing.

I have no problem starting up the indicator in the tab view's tabView:willSelectTabViewItem: delegate method, but I don't know where to stop it. Ideas?

You might want to rethink your design a bit. If your data source methods take too long to execute, they'll block the event loop and cause a "technicolor pizza" cursor. To avoid that, you could use threads to uncouple the display from the data source update.

In the data source, declare an iVar that holds the status of the data - empty, updating, or ready. Create a method that changes the status from empty to updating and then launches a separate thread to actually read the data. When that thread finishes, it should update the status to ready, fire off a notification (to the main thread) that the data status has changed, and exit.

When the user switches tabs, check the status; if it's empty, start the spinner and tell the data source to start getting its data. If it's updating, enable the spinner. If it's ready, just tell the table view(s) to update. Your controller class should also listen for notifications fired from the data source; when it receives one, it should start or stop the spinner as appropriate, and tell the table view(s) to update.

If it's appropriate for your data, you could fire off the notifications for each new "chunk" of data as it arrives, instead of waiting for the entire operation to complete, causing the table view(s) to be incrementally updated.

Depending on how you're getting your data, you might not need a separate thread. If you're using the asynchronous methods from NSFileHandle, for example, you could simply fire off the notification each time your callback method is called.

sherm--
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >[Q] how to tell when drawing is done? (From: Steve Christensen <email@hidden>)

  • Prev by Date: Re: [Q] how to tell when drawing is done?
  • Next by Date: Re: [Q] how to tell when drawing is done?
  • Previous by thread: Re: [Q] how to tell when drawing is done?
  • Next by thread: Re: [Q] how to tell when drawing is done?
  • Index(es):
    • Date
    • Thread