要迭代我的macOS应用中的所有窗口,我使用enumerateWindows(options:using:)
,如下所示:
NSApplication.shared.enumerateWindows(options: .orderedFrontToBack, using: {
(window: NSWindow, stop: UnsafeMutablePointer<ObjCBool>) in
if let vc = window.contentViewController as? SomeCustomViewController {
if someCondition {
stop = true // “Cannot assign to value: 'stop' is a 'let' constant”
}
}
})
我希望在符合someCondition
时停止枚举,但我无法将UnsafeMutablePointer<ObjCBool>
设置为true
:Xcode告诉我stop
是let
1}}常数。
我做错了什么?
答案 0 :(得分:1)
stop
是指针,您必须设置pointee
stop.pointee = true