【发布时间】:2021-10-11 15:58:39
【问题描述】:
我正在编写一个存储有关其他应用程序的数据的应用程序。我可以很容易地找到当前最前面的应用程序及其信息:
let frontApp = NSWorkspace.shared.frontmostApplication!
从那里我可以得到:
let currentAppName = currentApp.localizedName ?? "Dunno"
let currentAppIcon = currentApp.icon
如果应用程序不在前台,我知道我可以遍历其他正在运行的应用程序:
let apps = NSWorkspace.shared.runningApplications
for app in apps as [NSRunningApplication] {
print(app.localizedName ?? "whatever")
print(app.bundleIdentifier ?? "bundle")
}
我想获得有关当前未运行但我确实拥有捆绑标识符的应用程序的相同信息。我怎样才能得到这个?
【问题讨论】: