0

Disclaimer: I am a complete no0b when it comes to swift. I learn by examples so I am trying to write a simple swift app that will ping, and display the results into a scrollview box. Here is my code.

I keep getting that error at my println code

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)")





}




}
JonnyTombstone
  • 219
  • 1
  • 2
  • 6
  • 1
    `let println = textWindow ... println(...)` ???? – Martin R Dec 03 '16 at 18:21
  • Have a look at http://stackoverflow.com/questions/25179008/display-text-using-a-nsscrollview about adding text to a scroll view. – Martin R Dec 03 '16 at 18:24
  • Thanks Martin R. I figured it out. =) I don't know what I was doing with println but I figured out you don't point to the scroll view you have to point to the text view inside the scroll view. – JonnyTombstone Dec 07 '16 at 11:55

0 Answers0