I\'m using this code to bring up my window:
[self.window makeKeyAndOrderFront:self];
[self.window setOrderedIndex:0];
But often it will be
NSApp.activate(ignoringOtherApps: true)
The syntax seems to be a little different with Swift 2:
NSApplication.sharedApplication().activateIgnoringOtherApps(true)
Swift 2.0
NSApp.activateIgnoringOtherApps(true)
Helpful Programming Tips and Hacks
Perhaps you want:
[self.window setCollectionBehavior: NSWindowCollectionBehaviorCanJoinAllSpaces];
Experiment with the other collection behaviors... I found NSWindowCollectionBehaviorMoveToActiveSpace
was a bit buggy in 10.5 but it might be better now.
But how to move the app to the user's current Space?
You don't. Spaces hold windows, not applications. (That's why the collectionBehavior
property is on NSWindow, not NSApplication.)
To bring your app to the front:
[NSApp activateIgnoringOtherApps:YES];
Swift:
NSApp.activateIgnoringOtherApps(true)
Swift 3:
NSApp.activate(ignoringOtherApps: true)