In Objective-C for Cocoa Apps it's possible to use such way to keep window always on top?
How to achieve the same with Swift?
self.view.window?.level = NSFloatingWindowLevel
Causes build error Use of unresolved identifier 'NSFloatingWindowLevel'
I would prefer this way. This ignores all other active apps, and makes your app upfront.
To change the window level you can't do it inside viewDidload because view's window property will always be nil there but it can be done overriding viewDidAppear method or in a IBAction method:
Swift 1
Swift 2
Swift 3
Swift 4
Finally they fixed the odd syntax: