To iterate over all windows in my macOS app, I use enumerateWindows(options:using:)
like this:
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”
}
}
})
I want to stop the enumeration when someCondition
is met, but I can’t set the UnsafeMutablePointer<ObjCBool>
to true
: Xcode tells me that stop
is a let
constant.
What am I doing wrong?
stop
is a pointer, you have to set the pointee
stop.pointee = true