如何访问通知(基础 class)而不是我的(自定义 class 命名通知)?

How do I access the Notification (foundation class) and not my (custom class named Notification)?

问题是,我想在我的扩展文件上创建一个如下所示的扩展。

extension Notification.Name {
    static let value = Notification.Name(rawValue: "value")
}

但不幸的是,它正在读取我自定义的 class 命名通知,这次我只想直接访问基础...所以我可以转到 .Name

除了方法之外,还有像@DoNotReadCustomClass 这样的android 中提及的方法吗?哈哈之类的?

@onlyGoForFundationClass? @exeptionForThisTimeOnCustomClass 或类似的东西?

谢谢。

您可以在其前面加上声明 class 的模块的名称。在这种情况下,它将是:

extension Foundation.Notification.Name {
    static let value = Foundation.Notification.Name(rawValue: "value")
}