• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: using printf to print objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >using printf to print objects (From: mail4 <email@hidden>)
 >Re: using printf to print objects (From: Gwynne <email@hidden>)
 >Re: using printf to print objects (From: Glenn Andreas <email@hidden>)
 >Re: using printf to print objects (From: Eric Ocean <email@hidden>)

  • Prev by Date: WebView Auto-Load
  • Next by Date: Re: Preferences and Toolbars
  • Previous by thread: Re: using printf to print objects
  • Next by thread: Re: using printf to print objects
  • Index(es):
    • Date
    • Thread