An object that can manipulate and provide information for a single instance of an app.
- macOS 10.6+
Some properties of an app are fixed, such as the bundle identifier. Other properties may vary over time, such as whether the app is hidden. Properties that vary can be observed with key-value observing, in which case the description comment for the method notes this capability.
Properties that vary over time are inherently race-prone. For example, a hidden app may unhide itself at any time. To ameliorate this, properties persist until the next turn of the main run loop in a common mode. For example, if you repeatedly poll an unhidden app for its hidden property without allowing the run loop to run, it will continue to return
NO, even if the app hides, until the next turn of the run loop.
NSRunning is thread safe, in that its properties are returned atomically. However, it is still subject to the main run loop policy described above. If you access an instance of
NSRunning from a background thread, be aware that its time-varying properties may change from under you as the main run loop runs (or not).
NSRunning instance remains valid after the app exits. However, most properties lose their significance, and some properties may not be available on a terminated application.