updating UI during long loop using cocoa objective-c
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