• 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: Omar Qazi <email@hidden>
  • Date: Sun, 6 Jul 2008 23:24:51 -0700


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];
}


This is what I'm using in one of my Cocoa apps. I don't know if it's faster, but I would assume so, since there is no loop. Also, If i've interpreted the documentation correctly, the method is run in the main thread so you don't have to worry about anything being thread safe.

Omar Qazi
Hello, Galaxy!
1.310.294.1593

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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: Andrew Farmer <email@hidden>
References: 
 >Efficiently receiving data from an NSTask (From: "Martin Hairer" <email@hidden>)

  • Prev by Date: Re: Mysterious NULL Coming From NSUserDefaults
  • Next by Date: Re: Efficiently receiving data from an NSTask
  • Previous by thread: Efficiently receiving data from an NSTask
  • Next by thread: Re: Efficiently receiving data from an NSTask
  • Index(es):
    • Date
    • Thread