Fwd: NSThread call back...
Fwd: NSThread call back...
- Subject: Fwd: NSThread call back...
- From: "Brian O'Brien" <email@hidden>
- Date: Wed, 9 Nov 2005 11:50:22 -0700
On 9-Nov-05, at 10:57 AM, Chris Hanson wrote:
On Nov 9, 2005, at 9:25 AM, Brian O'Brien wrote:
When an NSThread wishes to communicate with the object that
created it,
how can one arrange that the thread calls a method of the creator
class?
Is this one possible use of the withObject parameter of the
NSThread detechNewThreadSelector method?
If so what is the syntax for passing the method as a parameter?
You can pass the detacher to the thread, and then invoke on the
detacher -performSelectorOnMainThread:withObject:waitUntilDone: to
have the specified selector invoked on the detacher.
detacher is the class that constructed the thread? So like... self?
This is the anObject parameter to myInstanceThreadMethod?
Ok so then I save a reference to anObject and call a well know
selector on that object.
[NSThread detachNewThreadSelector:@selector
(MyInstanceThreadMethod:) toTarget:myServer withObject:self];
- (void) MyInstanceThreadMethod:(id)anObject
{
parent = anObject;
// later on...
[parent wellKnowSelectorNameWithWellKnowParameter:10];
}
The -performSelectorOnMainThread sounds... tricky...
Rather than trying to pass a selector and object into your thread
(which you could pass as an NSInvocation) you can just pass an
object and have a well-known selector to send to that object from
the thread.
-- Chris
_______________________________________________
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