Re: using printf to print objects
Re: using printf to print objects
- Subject: Re: using printf to print objects
- From: Eric Ocean <email@hidden>
- Date: Fri, 22 Oct 2004 11:30:06 -0700
On Oct 22, 2004, at 11:13 AM, Glenn Andreas wrote:
At 12:38 PM -0400 10/22/04, Gwynne wrote:
On Oct 22, 2004, at 12:30 PM, mail4 wrote:
I like NSLog, yet I find it too verbose.
Instead, something like
printf( "%s", [[someObject description] UTF8String] )
That hardly fixes the "verbose" problem.
Here's a simpler solution:
#import <Foundation/Foundation.h>
#define CFLog(format, ...) CFShow( [NSString stringWithFormat:format, ##__VA_ARGS__] )
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *myString = @"Hello, World!";
CFLog( @"my log string with an object: %@", myString );
[pool release];
return 0;
}
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.
Regards,
Eric Ocean
_______________________________________________
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