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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -