Cocoa Multithreading question related to article

Discussion in 'Mac Programming' started by GorillaPaws, Aug 9, 2009.

  1. GorillaPaws macrumors 6502a

    GorillaPaws

    Joined:
    Oct 26, 2003
    Location:
    Richmond, VA
    #1
    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.
     
  2. SRossi macrumors regular

    Joined:
    May 27, 2009
    Location:
    Glasgow, Scotland
    #2
    Not too sure if this will help but I found a nice pdf from Apple. Find it here :).

    Stephen
     
  3. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #3
    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.
     
  4. GorillaPaws thread starter macrumors 6502a

    GorillaPaws

    Joined:
    Oct 26, 2003
    Location:
    Richmond, VA
    #4
    Thanks for the replies. As always, your help is greatly appreciated.
     

Share This Page