gpt4 book ai didi

macos - 快速类型转换

转载 作者:行者123 更新时间:2023-11-30 10:18:28 26 4
gpt4 key购买 nike

如何将 NSApplicationPresentationOptions 转换为 AnyObject?as 在这里不起作用。
我要打电话:

func enterFullScreenMode(_ screen: NSScreen, withOptions options: [NSObject: AnyObject]?) -> Bool

我有:

let presOptions: NSApplicationPresentationOptions =
.HideDock | // Dock is entirely unavailable. Spotlight menu is disabled.
.AutoHideMenuBar | // Menu Bar appears when moused to.
.DisableAppleMenu | // All Apple menu items are disabled.
.DisableProcessSwitching | // Cmd+Tab UI is disabled. All Exposé functionality is also disabled.
.DisableForceQuit | // Cmd+Opt+Esc panel is disabled.
.DisableSessionTermination | // PowerKey panel and Restart/Shut Down/Log Out are disabled.
.DisableHideApplication | // Application "Hide" menu item is disabled.
.AutoHideToolbar |
.FullScreen

let optionsDictionary = [NSFullScreenModeApplicationPresentationOptions: presOptions]

browserWindowController.containerView.enterFullScreenMode(NSScreen.mainScreen()!, withOptions: optionsDictionary)

这在最后一行给了我一个错误:

Cannot invoke 'enterFullScreenMode' with an argument list of type '(NSScreen, with Options: [String : NSApplicationPresentationOptions])'

最佳答案

根据documentation ,对应的值 key NSFullScreenModeApplicationPresentationOptionsNSNumber 的实例,其中包含 NSApplicationPresentationOptions 的无符号整数值,因此这应该有效:

let optionsDictionary = [NSFullScreenModeApplicationPresentationOptions : 
NSNumber(unsignedLong: presOptions.rawValue)]

关于macos - 快速类型转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28773101/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com