• 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: updating UI during long loop using cocoa objective-c
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: updating UI during long loop using cocoa objective-c


  • Subject: Re: updating UI during long loop using cocoa objective-c
  • From: Jerry Krinock <email@hidden>
  • Date: Sat, 31 Mar 2007 21:54:23 -0700


On 2007 Mar, 31, at 20:45, I. Savant wrote:


Well, without a separate thread, you could tell your table view or window to -display on each iteration. That'll force the display to update, but since you're blocking the main thread with your for loop, you'll still get the beach ball (I believe).

What I.S. believes is correct. This won't work.

For a multi-threaded approach, you'll want to search this list's archives for the term "appkit thread safe" as there are a number of issues to consider carefully *before* you start changing your design.

Allow me to return some good advice someone gave me a few weeks ago: Before you delve into multithreading, consider running your window as a "modal session". Poorly documented, no sample code, but simple if you can get it to work. Start by reading the documentation for:
-[NSApplication beginModalSessionForWindow:]
It's really weird because the NSModalSession is a struct, but just go along with it. Another hint: Use the strangely-named method:
-runModalSession:
when you want to update your view.


If the only UI you need to be active is one window, the modal session will theoretically get you there with much less code and bugs than multithreading. (Of course, it is multithreading under the hood, but Apple has done all the hard parts for you.) I've used a modal session with a simple window that has a progress bar and a Cancel button. I guess it should work with a table, but that might be pushing the envelope. Good luck and let us know if it works. _______________________________________________

Cocoa-dev mailing list (email@hidden)

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: updating UI during long loop using cocoa objective-c
      • From: "Corey O'Connor" <email@hidden>
References: 
 >updating UI during long loop using cocoa objective-c (From: <email@hidden>)
 >Re: updating UI during long loop using cocoa objective-c (From: "I. Savant" <email@hidden>)

  • Prev by Date: Re: updating UI during long loop using cocoa objective-c
  • Next by Date: Re: updating UI during long loop using cocoa objective-c
  • Previous by thread: Re: updating UI during long loop using cocoa objective-c
  • Next by thread: Re: updating UI during long loop using cocoa objective-c
  • Index(es):
    • Date
    • Thread