Unable to use DistributedNotificationCenter

Hi. I am currently implementing inter-application communication using DistributedNotificationCenter within swift 5.6 and Xcode Version 13.3.1 (13E500a).

So I typed the code below into Playground, but I get the error "Cannot find 'DistributedNotificationCenter' in scope".

import Foundation

let dnc = DistributedNotificationCenter.default()

As this document says, DistributedNotificationCenter is included in the Fundation, so I should be able to use it if I write it that way, but I can't.

I would appreciate it if you could tell me how I can use DistributedNotificationCenter

Thanks,

Accepted Reply

Just make sure the playgrounds settings platform is configured for macOS and not iOS.

  • Thank you for your kind reply.

    When I made the changes as you suggested, I was able to use DispatchNotificationCenter. I had overlooked the Availability in the documentation. Thanks,

Add a Comment

Replies

Just make sure the playgrounds settings platform is configured for macOS and not iOS.

  • Thank you for your kind reply.

    When I made the changes as you suggested, I was able to use DispatchNotificationCenter. I had overlooked the Availability in the documentation. Thanks,

Add a Comment

The statement below was posted by mistake. My apologies.

Thank you for your kind reply.

When I made the changes as you suggested, I was able to use DispatchNotificationCenter.

I had overlooked the Availability in the documentation.

Thanks,