• 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: [[NSNotificationCenter defaultCenter] postNotificationName] from a thread?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [[NSNotificationCenter defaultCenter] postNotificationName] from a thread?


  • Subject: Re: [[NSNotificationCenter defaultCenter] postNotificationName] from a thread?
  • From: "Alastair J.Houghton" <email@hidden>
  • Date: Sat, 1 Nov 2003 21:34:48 +0000

On Saturday, November 1, 2003, at 08:12 pm, Michael Rothwell wrote:

I'm writing an application that has several worker threads and uses
notifications. i'm worried about thread safety. In the worker threads,
I'm sending notifications back to the main thread like this:

[[NSNotificationCenter defaultCenter]
postNotificationName:@"UPnPDiscovery" object:self userInfo:d];

The main thread has registered for these notifications, and runs a
method, etc.

Should I be doing something to ensure thread safety?

I'm not certain whether NSNotificationCenter is thread safe, but it's much easier to use NSObject's -performSelectorOnMainThread:withObject:waitUntilDone: method, at least at long as you don't mind a requirement of Mac OS X 10.2 or later.

For Mac OS X 10.1 and earlier, the usual technique seems to be to use Distributed Objects to communicate with the main thread.

Kind regards,

Alastair.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: [[NSNotificationCenter defaultCenter] postNotificationName] from a thread?
      • From: Michael Rothwell <email@hidden>
References: 
 >[[NSNotificationCenter defaultCenter] postNotificationName] from a thread? (From: Michael Rothwell <email@hidden>)

  • Prev by Date: Re: TableView formatting and "small" NSButton questions
  • Next by Date: Re: My app crashes on Panther randomly
  • Previous by thread: [[NSNotificationCenter defaultCenter] postNotificationName] from a thread?
  • Next by thread: Re: [[NSNotificationCenter defaultCenter] postNotificationName] from a thread?
  • Index(es):
    • Date
    • Thread