• 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: problem with NSFileHandle's readDataToEndOfFile
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem with NSFileHandle's readDataToEndOfFile


  • Subject: Re: problem with NSFileHandle's readDataToEndOfFile
  • From: matt neuburg <email@hidden>
  • Date: Fri, 27 Dec 2002 10:49:22 -0800

On Thu, 26 Dec 2002 13:42:06 -0500, Josh Anon <email@hidden> said:

>
>Hi all,
>My app makes an NSTask which calls a program that makes a large (> 30
>MB) image and dumps it to standard out. What I'm trying to do is then
>read the output and create a NSBitmapImageRep from it. The code is
>basically:
>
>NSTask *myTask;
>NSPipe *outPipe = [NSPipe pipe];
>NSFileHandle *readHandle = [outPipe fileHandleForReading];
>NSData *imageData;
>//...
>[task setStandardOutput:outPipe];
>[task setLaunchPath:somePath];
>[task launch];
>//* bookmark
>imageData = [NSData dataWithData:[readHandle readDataToEndOfFile]];
>rep = [NSBitmapImageRep imageRepWithData:imageData];
>
>the problem is that imageData is only ~1/2 as long as it should be,

Isn't the problem just that you're calling readHandle too soon? If I understand the docs correctly, you should be reading from a different method, one that is set going by a notification that the data is ready. I think endingtask.html (it's on your hard drive) and the NSFileHandle docs (read..andNotify) would be useful here. m.

matt neuburg, phd = email@hidden, http://www.tidbits.com/matt
pantes anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: More Info: Help Using Malloc Debug
  • Next by Date: Re: Questions about retain
  • Previous by thread: problem with NSFileHandle's readDataToEndOfFile
  • Next by thread: Re: problem with NSFileHandle's readDataToEndOfFile
  • Index(es):
    • Date
    • Thread