如何修复错误"无法调用非功能类型的值' NSScrollView?"

时间:2016-12-03 18:19:08

标签: swift nsscrollview

免责声明:谈到swift,我是一个完整的no0b。我通过示例学习,所以我正在尝试编写一个简单的swift应用程序来ping,并将结果显示在scrollview框中。这是我的代码。

我一直在我的println代码中收到错误

import Cocoa
import Foundation
import CoreFoundation


class ViewController: NSViewController {

@IBOutlet weak var window: NSWindow!
@IBOutlet weak var textWindow: NSScrollView!
@IBOutlet weak var timer: NSProgressIndicator!




override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
}

override var representedObject: Any? {
    didSet {
    // Update the view, if already loaded.
    }
}


    @IBAction func Run(_ sender: Any) {



        func executeCommand(command: String, args: [String]) -> String {

            let task = Process()

            task.launchPath = command
            task.arguments = args

            let pipe = Pipe()
            task.standardOutput = pipe
            task.launch()

            let data = pipe.fileHandleForReading.readDataToEndOfFile()
            let output: String = NSString(data: data, encoding:      String.Encoding.utf8.rawValue) as! String

            return output

        }
        let println = textWindow
        let commandOutput = executeCommand(command: "/bin/sh", args: ["-c",   "ping -c 5 8.8.8.8"])
        println("Command output: \(commandOutput)")





}




}

0 个答案:

没有答案