• 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: "I. Savant" <email@hidden>
  • Date: Sat, 31 Mar 2007 23:45:00 -0400


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).


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.

--
I.S.


On Mar 31, 2007, at 11:26 PM, <email@hidden> <email@hidden> wrote:


I want to update my UI after each iteration of a long loop in a
objective-c cocoa application.
for(i = 0; i < loopMax; i++)
{
   // do lots of processing

   [myTableView reloadData]; // also update progress indicators
}

The above code simply causes the dreaded spinning beachball to occur and
does not update mytable until end of method loop is containd in.


I created a class "MyUiUpdater" which updates progress bars and tables in
method "updateUI",which I call from the loop. Unfortunately the same situation occurs.


I then tried to thread the application using NSThread but had difficulty
implementing correctly.
Questions:
-What is a straight forward way to update my UI after each iteration of
the loop?-Is threading absolutely necessary?
- If so can I simply create a pthread to run method [MyDataProcessor
processData] which calls[MyUiUpdater updateDisplay] at the end of each iteration and use a mutex
lock?- Is there a tutorial or example cocoa application available which someone
could point metowards?




_______________________________________________

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:
40gmail.com


This email sent to email@hidden

_______________________________________________

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: Jerry Krinock <email@hidden>
References: 
 >updating UI during long loop using cocoa objective-c (From: <email@hidden>)

  • Prev by Date: 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: 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