• 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: Efficiently receiving data from an NSTask
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Efficiently receiving data from an NSTask


  • Subject: Re: Efficiently receiving data from an NSTask
  • From: Andrew Farmer <email@hidden>
  • Date: Sun, 6 Jul 2008 23:36:37 -0700

On 06 Jul 08, at 23:24, Omar Qazi wrote:
On Jul 6, 2008, at 7:46 AM, Martin Hairer wrote:
This works like a treat and is faster by a factor 3 or so than using
the "Moriarity" implementation. However, it leaves me a bit concerned
about various warnings all over the place concerning the thread
(un)safety of NSTask and NSFileHandle. So my question is: is the kind
of approach that I am taking doable / reasonable? If not, is there an
alternative way of doing this which is more efficient  than the
"Moriarty" code? Thanks a lot in advance for any help / hint,

NSFileHandle *msgHandle = [standardInput fileHandleForReading]; [msgHandle waitForDataInBackgroundAndNotify];

- (void)newMessage:(NSNotification *)notification {
NSString *strOutput = [[NSString alloc]initWithData:[msgHandle availableData] encoding:NSUTF8StringEncoding];
//Process the data
[msgHandle waitForDataInBackgroundAndNotify];
}

I'd be very careful with reading string input like that. It's entirely possible for a multi-byte character (é, for example, is represented as C3 89) to be split across two separate data chunks, which'll make NSString very confused and angry.


I'm not quite sure what the correct solution is here, though. There's got to be some easier solution than checking for sequence completeness by hand..._______________________________________________

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: Efficiently receiving data from an NSTask
      • From: "Michael Ash" <email@hidden>
References: 
 >Efficiently receiving data from an NSTask (From: "Martin Hairer" <email@hidden>)
 >Re: Efficiently receiving data from an NSTask (From: Omar Qazi <email@hidden>)

  • Prev by Date: Re: Efficiently receiving data from an NSTask
  • Next by Date: NSSound won't play wave files???
  • Previous by thread: Re: Efficiently receiving data from an NSTask
  • Next by thread: Re: Efficiently receiving data from an NSTask
  • Index(es):
    • Date
    • Thread