Re: Save Output of NSTask to file
Re: Save Output of NSTask to file
- Subject: Re: Save Output of NSTask to file
- From: Sherm Pendley <email@hidden>
- Date: Tue, 7 Dec 2004 04:28:48 -0500
On Dec 7, 2004, at 3:52 AM, Bjorn Van Blanckenberg wrote:
How can I save the output of NSTask to a file and show it in textview
Instead of an NSPipe, create an instance of NSFileHandle that's been
opened to write to a file. Pass that file handle to NSTask's
setStandardOutput: and/or setStandardError: methods, depending on which
of the two output streams you want to save in the file you've opened.
One common way to display a file that's being written to is to launch a
background thread that repeatedly checks the file's size. If it's grown
since the last check, you send a message to the main thread. The main
thread would then add the new data from the file to the text view.
(Methods that access interface elements should only be called from the
main thread.)
Depending on how responsive you want your text view to be, you could
insert a delay between checks in the background thread. For extra
credit, you could even make the delay user-configurable.
sherm--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden