Search code examples
iosswiftobservers

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


Problem is, I want to create an extension on my Extension file something like below.

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

But unfortunately, it is reading my custom class named Notification, and I just want to access directly to the foundation this time... so I can go to .Name

Is there some way like mentions as in android like @DoNotReadCustomClass just besides the method? haha or something like that?

@onlyGoForFundationClass? @exeptionForThisTimeOnCustomClass or something like that?

thanks.


Solution

  • You can prefix it with the name of the module that declares the class. In this case it would be:

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