• 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: Passing arguments to threads?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing arguments to threads?


  • Subject: Re: Passing arguments to threads?
  • From: Mai Bui <email@hidden>
  • Date: Mon, 20 Dec 2004 15:00:49 -0800

Hi,

How can I pass C-structrure (as pass reference) to thread?
For example:

typedef struct MyCStruct{
.... member ....
}MyCStruct, *MyCStructPtr;


-(void) MymainRoutine
{
MyCStructPtr localCStructPtr;
....
[NSThread detachNewThreadSelector: @selector(MyRoutine) toTarget:self withObject:localCStructPtr];
....
}

- (void)MyRoutine: (MyCStructPtr) mcstruct
{
..... change member of the MyCStruct here....
}

Is it correct?

Thanks for your ideas in advance.

Mai.
<x-tad-bigger>
</x-tad-bigger>
On Nov 18, 2004, at 8:35 AM, Damien Bobillot wrote:

Le 18 nov. 04, à 17:17, Dan Saul a écrit :

I'm relatively new to the objC Cocoa scene and I was wondering about
something taht should be relatively simple, i've looked at the
NSThread documentation and I was wondering how to detach a thread and
pass some arguments/values to it.

Is this possible?

Yes with the NSThread class method :
<x-tad-bigger>+ (void)detachNewThreadSelector:(SEL)aSelector toTarget:(id)aTarget withObject:(id)anArgument</x-tad-bigger>

there's only one argument, but you may given an NSArray, NSDictionary, C structure, any Objective-C object…
--
Damien alias Schmurtz
aim:goim?screenname=schmuuurtz
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Passing arguments to threads?
      • From: "John C. Randolph" <email@hidden>
  • Prev by Date: Re: -(NSString *)description method not called in Cocoa app
  • Next by Date: NSBeginAlertSheet (II)
  • Previous by thread: Re: iCal Alarms
  • Next by thread: Re: Passing arguments to threads?
  • Index(es):
    • Date
    • Thread