Window in all spaces

macOS, Swift, storyboards

How can I make the window active in all spaces?

I could find how to do that with storyboard: Select the window > Attributes > Spaces > Can join all spaces. How can I do the same with code (activate and de-activate)
Answered by parker9 in 714762022
let window : NSWindow? = nil
...
window?.collectionBehavior = .canJoinAllSpaces    // window will be in all Spaces
window?.collectionBehavior = .moveToActiveSpace // when window is activated, move to active Space
window?.collectionBehavior = .stationary // Expose doesn't affect window, so it stays visible and stationary, like the Desktop window
window?.collectionBehavior = .managed // window participates in Spaces and Expose (i.e. normal window). 

there are other options....

Accepted Answer
let window : NSWindow? = nil
...
window?.collectionBehavior = .canJoinAllSpaces    // window will be in all Spaces
window?.collectionBehavior = .moveToActiveSpace // when window is activated, move to active Space
window?.collectionBehavior = .stationary // Expose doesn't affect window, so it stays visible and stationary, like the Desktop window
window?.collectionBehavior = .managed // window participates in Spaces and Expose (i.e. normal window). 

there are other options....

Window in all spaces
 
 
Q