2

I am having trouble with the window level constants such as NSScreenSaverWindowLevel. Swift complains about unresolved identifier. I couldn't find an enum equivalent of these levels either ? Is this possible currently ?

I'm trying to use:

window.level = NSScreenSaverWindowLevel // unresolved identifier
David Berry
  • 40,941
  • 12
  • 84
  • 95
pavanpodila
  • 76
  • 1
  • 6

1 Answers1

8

Following through the chain of defines:

#define NSScreenSaverWindowLevel     kCGScreenSaverWindowLevel

and...

#define kCGScreenSaverWindowLevel     CGWindowLevelForKey(kCGScreenSaverWindowLevelKey)   /* 1000 */

I think the corrected answer is:

window.level = Int(CGWindowLevelForKey(Int32(kCGScreenSaverWindowLevelKey)))

much casting because of discrepancies in enum types

David Berry
  • 40,941
  • 12
  • 84
  • 95
  • I think this definitely answers the question. One might add that `NSScreenSaverWindowLevel` was an alias for `kCGScreenSaverWindowLevelKey`, though. – nschum Jun 11 '14 at 18:00
  • 1
    The solution by @david works but is definitely very ugly. Something Apple must fix in the next drop – pavanpodila Jun 13 '14 at 14:44
  • 1
    `window.level = Int(CGWindowLevelForKey(CGWindowLevelKey.CursorWindowLevelKey))` now works – Klaas Jan 31 '16 at 14:12