• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Returning value from detached NSThread selector with multiple arguments.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Returning value from detached NSThread selector with multiple arguments.


  • Subject: Re: Returning value from detached NSThread selector with multiple arguments.
  • From: Graham Cox <email@hidden>
  • Date: Thu, 8 Jan 2009 12:42:28 +1100


On 8 Jan 2009, at 12:28 pm, John Cassington wrote:

After testing, the dictionary concept works perfectly! Thanks!

With regard to the originating thread retaining a reference to the
dictionary, is there a way for the original thread to know when
processing has completed on the secondary thread?

I would like my method to be run on a separate thread, but be able to
return a value to the caller in the normal fashion.


Threads are able to access the same data, including the originating object. Indeed, it is likely to be running as a method of the originating object. So just set up a callback that you call when done. Using -performSelectorOnMainThread:withObject:waitUntilDone: is useful to make sure that you bounce the completion functionality back to the main thread and not run it from your secondary thread.

There seems to be a misconception about threads that they are totally sealed off from the rest of your program. That's not the case - in fact, therein lies the trickiness of threads - you need to be mindful about the possibility of the same data being accessed from different threads.

--Graham


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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


References: 
 >Returning value from detached NSThread selector with multiple arguments. (From: "John Cassington" <email@hidden>)
 >Re: Returning value from detached NSThread selector with multiple arguments. (From: Graham Cox <email@hidden>)
 >Re: Returning value from detached NSThread selector with multiple arguments. (From: "John Cassington" <email@hidden>)

  • Prev by Date: Re: NSOperation Question
  • Next by Date: Re: Returning value from detached NSThread selector with multiple arguments.
  • Previous by thread: Re: Returning value from detached NSThread selector with multiple arguments.
  • Next by thread: Re: Returning value from detached NSThread selector with multiple arguments.
  • Index(es):
    • Date
    • Thread