• 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
Fwd: NSThread call back...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: NSThread call back...
      • From: Chris Hanson <email@hidden>
  • Prev by Date: Re: mysterious memory leak in cocoa ? (FOLLOWUP)
  • Next by Date: Re: From Main Bundle's Resource folder: How can I load similar resources (png images) from different sub-folders into their respective NSArrays?
  • Previous by thread: Re: NSThread call back...
  • Next by thread: Re: NSThread call back...
  • Index(es):
    • Date
    • Thread