I haven't followed the whole thread, but be aware that NSNotificationCenter uses weak references. I'm not sure that's the problem you are encountering since I was too lazy to read your other msgs (sorry), but hopefully that comment might help you or others. - Matt Sent from my iPhone On Oct 9, 2011, at 0:58, Alex Greif <alex@greifdesign.net> wrote:
here an update: the problem seems to be with the notifier, because if I use the following code without the NSNotificationCenter, then, everything works fine, like the following sample code:
task = NSTask.alloc.init task.currentDirectoryPath = "/" task.launchPath = "/bin/bash" task.arguments = ["some script"]
stdout_pipe = NSPipe.pipe task.setStandardOutput stdout_pipe stdout_file_handle = stdout_pipe.fileHandleForReading
task.launch task.waitUntilExit exit_status = task.terminationStatus
stdout_data = stdout_file_handle.readDataToEndOfFile stdout = NSString.alloc.initWithData(stdout_data, encoding:NSUTF8StringEncoding)
Does anybody have such bad experiences with the NSNotificationCenter?
ALex.
Hi
I tried the subprocess sample with the AsyncHandler from http://ofps.oreilly.com/titles/9781449380373/_foundation.html
and found the following problem: if I execute the code many times (I tried 20 times) in my terminal with $ macruby sample.rb then 2-3 times it does not print any output. In this 10% the data_ready: method of the AsyncHandler is not called.
Is this a macruby problem or an NSTask problem?
BTW using NSFileHandleReadToEndOfFileCompletionNotification instead of NSFileHandleReadCompletionNotification makes it even worse, in this case data_ready: is never called.
I use the 2011.09.27 macruby 0.11 snapshot and mac os x 10.6.8
Alex.
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel