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

updating UI during long loop using cocoa objective-c


  • Subject: updating UI during long loop using cocoa objective-c
  • From: <email@hidden>
  • Date: Sat, 31 Mar 2007 22:26:41 -0500 (CDT)
  • Importance: Normal

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: updating UI during long loop using cocoa objective-c
      • From: "I. Savant" <email@hidden>
  • Prev by Date: Re: The how and why of Cocoa.
  • Next by Date: Re: updating UI during long loop using cocoa objective-c
  • Previous by thread: Re: The how and why of Cocoa.
  • Next by thread: Re: updating UI during long loop using cocoa objective-c
  • Index(es):
    • Date
    • Thread