Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

updating UI during long loop using cocoa objective-c



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.