Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

GorillaPaws

macrumors 6502a
Original poster
Oct 26, 2003
932
8
Richmond, VA
So I just read an interesting article on multithreading by Matt Gallagher on his blog "Cocoa with Love."

I don't have any multithreading experience, so it was interesting to see that there are ways of multithreading that aren't insanely difficult to comprehend. My main question is whether the technique described here would allow for the worker thread to update the GUI. So in Gallagher's example, would it be possible to include a progress bar in the bottom of the window while remaining thread-safe? Or would interaction with the view necessitate a different (more complex) multithreading technique?

Thanks in advance for any clarification you could provide.
 
Those methods with the onThread: argument are 10.5+, so watch out for that if you need backwards compatibility.

If your thread needs to update the UI, the easiest way to do this is via the performSelectorOnMainThread:withObject:waitUntilDone: method. If you need to pass multiple arguments or non-object arguments, you can use this method along with NSInvocation.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.