Re: NSTask with unzip
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