This repository was archived by the owner on Oct 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathViewControllerInformation.swift
60 lines (51 loc) · 1.68 KB
/
ViewControllerInformation.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// ViewControllerInformation.swift
// RsyncOSXver30
//
// Created by Thomas Evensen on 24/08/2016.
// Copyright © 2016 Thomas Evensen. All rights reserved.
//
// swiftlint:disable line_length force_cast
import Cocoa
import Foundation
class ViewControllerInformation: NSViewController, SetDismisser, OutPut {
@IBOutlet var detailsTable: NSTableView!
var output: [String]?
override func viewDidLoad() {
super.viewDidLoad()
detailsTable.delegate = self
detailsTable.dataSource = self
}
override func viewDidAppear() {
super.viewDidAppear()
output = getinfo()
globalMainQueue.async { () in
self.detailsTable.reloadData()
}
}
@IBAction func close(_: NSButton) {
dismissview(viewcontroller: self, vcontroller: .vctabmain)
}
@IBAction func pastetabeltomacospasteboard(_: NSButton) {
let pasteboard = NSPasteboard.general
pasteboard.clearContents()
for i in 0 ..< (output?.count ?? 0) {
pasteboard.writeObjects([output?[i] as! NSPasteboardWriting])
}
}
}
extension ViewControllerInformation: NSTableViewDataSource {
func numberOfRows(in _: NSTableView) -> Int {
return output?.count ?? 0
}
}
extension ViewControllerInformation: NSTableViewDelegate {
func tableView(_ tableView: NSTableView, viewFor _: NSTableColumn?, row: Int) -> NSView? {
if let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "outputID"), owner: nil) as? NSTableCellView {
cell.textField?.stringValue = output?[row] ?? ""
return cell
} else {
return nil
}
}
}