Jump to content

update UI from worker thread


  • Please log in to reply
2 replies to this topic

#1
MacBgnr

MacBgnr

    InsanelyMac Protégé

  • Members
  • Pip
  • 6 posts
Hello,

I am using NSThread to create a worker thread for a long task. However, from the main method of the worker thread, I want to Update some UI elements. How can I do this?

#2
stroke

stroke

    InsanelyMac Sage

  • Members
  • PipPipPipPipPip
  • 350 posts
  • Location:Russia
You can send an NSNotification to a controller object registered for that notification, or you can use NSObject's performSelectorOnMainThread:withObject:waitUntilDone: method.

#3
MacBgnr

MacBgnr

    InsanelyMac Protégé

  • Members
  • Pip
  • 6 posts
Thanks for the helpful reply.

I have implemented performSelectorOnMainThread:withObject:waitUntilDone. However, it looks like that it works when waitUntilDone is set to YES or when using sleep(1). The selector does not get called if I use waitUntilDone = NO and dont use sleep().

Any ideas how this can be resolved?





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy