When upgrading my xcode from 8.0 to 8.1 and Swift to 3.0.1, I found that I can no longer compare type with implicitly unwrapped optional in a switch statement. I need to explicitly unwrap the optional
lately I had to deal with window layering and ordering is Swift. I had to make sure some windows are always on top of other windows. This can be done with window levels.
in objective-c I found that you can simply call [NSWindow setLevel] with defined values such as NSMainMenuWindowLevel. in Swift, these defines doesnt exist. we have to use CGWindowLevelKey enum
However, this enum is not a value we can use directly for NSWindow.level. We have to convert it to a usable value by using CGWindowLevelForKey(), which returned an Int32. Since NSWindow.level is an Int, we also have to cast it to Int.
window.level = Int(CGWindowLevelForKey(.normalWindow))
Here's the list of the values of CGWindowLevelKey sorted from bottom to top. At the time of this writing, these values are generated with Swift 3.0.1 and macOS 10.12 SDK