• 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: "John Cassington" <email@hidden>
  • Date: Thu, 8 Jan 2009 12:28:54 +1100

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.

Thanks,
John Cassington

On Thu, Jan 8, 2009 at 12:21 PM, Graham Cox <email@hidden> wrote:
>
> On 8 Jan 2009, at 12:13 pm, John Cassington wrote:
>
>> Hi,
>> I have a class (JCDataCollector) which I use to collect a large amount
>> of data from the users machine. JCDataCollector has a
>> publicly-accessible method named
>> "collectData:usingFile:shouldLogOutput:";. This method is very
>> resource-intensive, and I would like to move it onto its own thread.
>>
>> So far, I have been able to call the method using NSThread's
>> "detachNewThreadSelector:toTarget:withObject:" functionality.
>>
>> However, I cannot find a way to return the data collected in my
>> "collectData:usingFile:shouldLogOutput:"; method to the object which
>> originally detached the thread selector.
>>
>> Also, my "collectData:usingFile:shouldLogOutput:"; method takes
>> multiple arguments, but NSThread's
>> "detachNewThreadSelector:toTarget:withObject:" only allows one
>> parameter to be passed. Short of storing all the parameters in an
>> NSArray, is there any way to pass multiple parameters while calling
>> "detachNewThreadSelector:toTarget:withObject:"?
>
>
> Dictionaries are very useful for passing parameters, as you can name them
> and access them in arbitrary order.
>
> If you make it mutable, it solves your other problem too - just place the
> results in the same dictionary. The originating thread can retain a
> reference to it so you have a shared object through which the threads are
> able to communicate.
>
> --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

  • Follow-Ups:
    • Re: Returning value from detached NSThread selector with multiple arguments.
      • From: Ken Thomases <email@hidden>
    • Re: Returning value from detached NSThread selector with multiple arguments.
      • From: Graham Cox <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>)

  • Prev by Date: Tiger vs Leopard Printing
  • Next by Date: NSOutlineView indentation
  • 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