I want to display a list of all running application names.
Issue: It doesn't add an app that is running after the function is called. Therefore, it doesn't add the app name to the list simultaneously.
Goal: I want to add a listener, so if a new app is running it will add it to the array simultaneously without restarting the app or recalling the function again.
func allRunningApplications() {
for runningApplication in NSWorkspace.shared.runningApplications {
let appName = runningApplication.localizedName
// Add App Name to Array
array.append(appName)
}
}