Re: [NSString writeToFIle:atomically:encoding:error] to stdout?
Re: [NSString writeToFIle:atomically:encoding:error] to stdout?
- Subject: Re: [NSString writeToFIle:atomically:encoding:error] to stdout?
- From: Jens Alfke <email@hidden>
- Date: Sun, 11 May 2014 11:51:26 -0700
On May 11, 2014, at 6:40 AM, William Squires <email@hidden> wrote:
> Is there a way to have the above send the string's contents to stdout instead of a named file? If not, no biggy, I'll just make another method to output all the lines (in my NSArray, which I sent the componentsJoinedByString: message to get the NSString whose output I want to go to stdout), but it just adds unneeded complexity that I'd rather avoid. TIA!
I think what you’re saying is you want a single code-path for writing to a file and writing to stdout?
One way to do that is to use the pseudo-file /dev/stdout — anything written to that ‘file’ actually goes to stdout. But make sure not to use the ‘atomically’ option or NSString will actually write to a temp file and then try to move that file to /dev/stdout, which of course won’t work.
—Jens
_______________________________________________
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