swift - NSTask Output to Text View Sometimes Goes to Console -


directing output of nstask object text view works of commands i've tried, not git clone. in instance, output goes xcode console, even though have no print statements in code. code written below, goes console. if use commented out lines instead, output goes text view.

    var clonetask: nstask!     @iboutlet var tv: nstextview!      override func viewdidload() {         super.viewdidload()         clonetask = nstask()         clonetask.launchpath = "/usr/bin/git"         clonetask.arguments = ["clone", "https://github.com/edelmar/dht22_reader"]         //clonetask.launchpath = "/usr/bin/env"         //clonetask.arguments = ["pwd"]         clonetask.pipeoutputto(tv)         clonetask.launch()     } 

pipeoutputto: function in extension on nstask,

extension nstask {     func pipeoutputto(logger: anyobject) -> anyobject {         let pipe = nspipe()         self.standardoutput = pipe          let stdouthandle = pipe.filehandleforreading         stdouthandle.waitfordatainbackgroundandnotify()         let observer = nsnotificationcenter.defaultcenter().addobserverforname(nsfilehandledataavailablenotification, object: stdouthandle, queue: nil) { _ in             let dataread = stdouthandle.availabledata             let stringread = nsstring(data: dataread, encoding: nsutf8stringencoding)             logger.append(stringread as! string)             if stringread!.length > 0 {                 stdouthandle.waitfordatainbackgroundandnotify()             }         }         return observer     } } 

does know reason difference in behavior?


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -