Re: Write text to the stdout
Re: Write text to the stdout
- Subject: Re: Write text to the stdout
- From: Marcel Weiher <email@hidden>
- Date: Fri, 3 Jan 2003 15:31:20 +0100
On Friday, January 3, 2003, at 02:57 Uhr, Arthur VIGAN wrote:
I am programming a Foundation Tool for use with the terminal app, but
I have troubles to ouput text in the terminal (the stdout in this
case). The problem comes with the NSString. I can't use the printf()
function with NSString, so what should I use?
printf( "%s",[myString cString]);
or maybe lossyCString, as cString will raise an exception if some of
the characters aren't representable in the default cstring encoding
(usually MacOSRoman).
You can also use MPWFoundation's MPWByteStream class, which for an
isolated case would look like this:
[[MPWByteStream Stdout] writeObject:myString];
or
[outStream writeObject:myString];
if you have already gotten the Stdout stream earlier. The clue about
-writeObject: is that it will take any object whatsoever and print it
(to an arbitrary stream). The default behavior is to print the
-description, but objects can easily override that behavior.
Marcel
--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
_______________________________________________
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.