• 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: NSTask with unzip
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask with unzip


  • Subject: Re: NSTask with unzip
  • From: Dave DeLong <email@hidden>
  • Date: Sat, 27 Nov 2010 10:34:06 -0800

Something along the lines of:

NSString * tempFilePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"myTempFile.tmp"];
if (![[NSFileManager defaultManager] fileExistsAtPath:tempFilePath]) {
  [[NSFileManager defaultManager] createFileAtPath:tempFilePath contents:nil attributes:nil];
}

NSFileHandle * outHandle = [NSFileHandle fileHandleForWritingAtPath:tempFilePath];
[myTask setStandardOutput:outHandle];

....

NSString * output = [NSString stringWithContentsOfFile:tempFilePath encoding:NSUTF8StringEncoding error:nil];
[[NSFileManager defaultManager] removeItemAtPath:tempFilePath error:nil];

(typed in Mail.app. YMMV)

Dave

On Nov 27, 2010, at 10:29 AM, gMail.com wrote:

> How do you create the NSFileHandle ?
> I succeeded only creating it as
> NSFileHandle    *theFileH = [NSFileHandle
>     fileHandleForWritingAtPath:tempFilePath];
> and the file tempFilePath must exists.
>
> But as I said, I would like to get rid of the temp file.
>
> --
> Leo
_______________________________________________

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: 
 >Re: NSTask with unzip (From: "gMail.com" <email@hidden>)

  • Prev by Date: Re: NSTask with unzip
  • Next by Date: Re: iOS - Help with nasty memory leak
  • Previous by thread: Re: NSTask with unzip
  • Next by thread: Video player dead?
  • Index(es):
    • Date
    • Thread