When I try:
let center = DistributedNotificationCenter.default
center.postNotificationName(Notification.Name(rawValue: "SomeName"), object: "SomeString", deliverImmediately: true)
I get compiler error: Extra argument 'deliverImmediately' in call. What I'm trying to do is post a distributed notification from FileProvider extension. When I check documentation I see that deliverImmediately parameter exists.
Does anyone know what's going on there?
This compiles on my machine:
let name = Notification.Name(rawValue: "hello.cruel.world")
DistributedNotificationCenter.default().postNotificationName(name, object: nil, deliverImmediately: true)
I’m using Xcode 13.4.1 in a macOS command-line tool target.
You seem to be missing the parens after the default. This means that in your code center is the type, not an instance, and thus you end up trying to call class methods.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"