On Mac OS X Snow Leopard with fast user switching enabled, is there an API to detect whether or not my application is running in the active user session? I.e. the session cu
This worked for me (10.14 / Swift 4)
//Fast user switch out
NSWorkspace.shared.notificationCenter.addObserver(
self,
selector: #selector(becameInactive),
name: NSWorkspace.sessionDidResignActiveNotification,
object: nil
)
//Fast user switch bak in
NSWorkspace.shared.notificationCenter.addObserver(
self,
selector: #selector(becameActive),
name: NSWorkspace.sessionDidBecomeActiveNotification,
object: nil
)
// Switching workspace (spaces)
NSWorkspace.shared.notificationCenter.addObserver(
self,
selector: #selector(workspaceSwitched),
name: NSWorkspace.activeSpaceDidChangeNotification,
object: nil
)