Re: using printf to print objects
Re: using printf to print objects
- Subject: Re: using printf to print objects
- From: "M. Uli Kusterer" <email@hidden>
- Date: Sun, 24 Oct 2004 17:33:35 +0200
At 11:30 Uhr -0700 22.10.2004, Eric Ocean wrote:
The CFLog() macro should work with both format strings that take
arguments and those that don't.
It doesn't print out the exact same information as NSLog; instead it
print the CoreFoundation equivalent.
If anyone knows a way that NSLog could be cleanly formatted as a
macro that returned a string for printf or an NSString for CFShow to
use, that would be helpful.
Are you looking for something like CFCopyDescription()? That's the
CoreFoundation equivalent to [obj description] and returns a
CFStringRef. Since a CFStringRef is toll-free bridged to an NSString,
and a CFTypeRef is the CoreFoundation equivalent to "id", you could
thus do:
void MyLogObject( id obj )
{
NSString* str = (NSString*) CFCopyDescription( (CFTypeRef)obj );
printf("%s",[str UTF8String]);
[str release];
}
Is that useful?
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden