• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: How to...
      • From: Ken Thomases <email@hidden>
References: 
 >How to... (From: Charlie Dickman <email@hidden>)

  • Prev by Date: Re: Exception on ^⌘D when AppKit tries to use Lookup on my custom view
  • Next by Date: Re: Crash in heartbeat thread while progress indicator showing
  • Previous by thread: How to...
  • Next by thread: Re: How to...
  • Index(es):
    • Date
    • Thread