对具有 UI 的 运行 个应用程序进行排序的最佳方式 |斯威夫特3,macOS

Best way to sort through running apps that have UI | Swift3, macOS

所以我有一个分析 运行 个应用程序的应用程序,到目前为止我的代码

func running() -> [NSRunningApplication]{
    let base = NSWorkspace()
    let apps = base.runningApplications
    return apps
}

for app in running() {
    print(app.localizedName)
    print("isActive: \(app.isActive) | isHidden: \(app.isHidden) | ")

}

我可以确定很多属性. However I want to filter apps that have UI kind of like the ones in the Force Quit Applications menu:

那么关于如何过滤这些应用程序的任何提示?

过滤 activationPolicy == .regular

let apps = base.runningApplications.filter {[=10=].activationPolicy == .regular}

来源:NSApplicationActivationPolicy