Cannot find "UIScreen" in scope [duplicate]

I've just approached Swift, for building a quick utility app for my MacBook. I have written the following code, but it gives me the error "Cannot find 'UIScreen' in scope".

class AppDelegate: NSObject,NSApplicationDelegate{
    //...
    func applicationDidFinishLaunching(_ notification: Notification) {

        Timer.scheduledTimer(withTimeInterval: 10, repeats: true) { timer in
            UIScreen.mainScreen().brightness = CGFloat(0.0) //<- error here
        }
    }
    //...
}

Initially I thought I've missed an import, but I cannot find what to import (UIKit, is only for iOS). Thank you for any help


Solution 1:

Anything beginning with "UI" is an iOS class. Those classes are not available from a macOS app.

The equivalent class for macOS is probably NSScreen, although I don't think it has an exposed brightness property like the one you are trying to set.