Mac OSX Retrieves List of Applications Like Forced Close Applications

I would like to know if there is a way to get the list of applications similar to the list of Force Quit Applications Force removal of application list

I do not know that what I have written so far will allow me to receive such information.

extension ViewController: NSTableViewDelegate {

fileprivate enum CellIdentifiers {
    static let NameCell = "cell"
}

func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {

    var appName: String = ""
    var appIcon: NSImage?

    appName = applications[row].localizedName!
    appIcon = applications[row].icon

    if let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "applicationCell"), owner: nil) as? NSTableCellView {

        cell.textField?.stringValue = appName
        cell.imageView?.image = appIcon ?? nil
        print("created")

        return cell
    }
    return nil
}

When I debug, I get all the processes, but I only want to get a list of applications. This is an example of the results I get: enter image description here

We see that there are applications, but also all processes (which I do not want to have).

+4
source share
1 answer

Your code does not explain where you got your array from applications[], but I assume that it is an array of objects NSRunningApplicationreceived through runningApplications().

"" , .. , - , , .

, bundleURL. , .

NSBundle Info.plist (. infoDictionary). , , (CFBundlePackageType is APPL). , ..

, "" ( ), LSUIElement, 1.

, .

+1

Source: https://habr.com/ru/post/1693492/


All Articles