Re: How to...
Re: How to...
- Subject: Re: How to...
- From: Jens Alfke <email@hidden>
- Date: Thu, 09 Aug 2012 11:29:38 -0700
On Aug 9, 2012, at 10:00 AM, Charlie Dickman <email@hidden> wrote:
> NSTask *ls = [[NSTask alloc] init];
> NSFileHandle *stdIn = [NSFileHandle fileHandleForReadingAtPath: txtFilePath];
> [ls setStandardInput: stdIn];
> [ls setLaunchPath: @"/usr/bin/say"];
> [ls launch];
> [ls release];
>
> My problem is that the command speaks the text in the file when the task is launched but not anything written to it subsequently.
Yeah, when the NSFileHandle hits EOF on the file it will propagate the EOF to the task, which will then exit.
What you want instead is to make your own NSStream that isn't tied to a file. But looking at the NSTask and NSFileHandle APIs, I don't see how you can attach an NSStream to a task...
(Basically, the stream APIs in Cocoa suck. I don't know why this is; they're so important, there's plenty of prior art, and most other frameworks like Java managed to do them pretty well. But working with streams in Cocoa apps is usually a total mess.)
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >How to... (From: Charlie Dickman <email@hidden>) |