What is the closest Core Foundation function to the functionality of NSLog?
CoreFoundation is written in C while Foundation is written in Objective-C; Foundation has a lot more classes; CoreFoundation is the common base of Foundation and Carbon.
NSLog outputs messages to the Apple System Log facility or to the Console app (usually prefixed with the time and the process id).
CFShow()
is similar, but without the prefix stuff. Or, as wbyoung says, use NSLog()
. If you don’t want to use Objective-C, the following is perfectly valid (although it requires linking against Foundation.framework):
#if __cplusplus
extern "C" {
#endif
void NSLog(CFStringRef format, ...);
void NSLogv(CFStringRef format, va_list args);
#if __cplusplus
}
#endif
int main (int argc, const char * argv[])
{
NSLog(CFSTR("Hello, World! %u"), 42);
return 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With