是否可以在没有时间和日期戳的情况下使用NSLog()以及自动换行符?
问题描述:
NSLog()是否具有不带时间和日期戳以及自动换行符打印的变体?
Does NSLog() have variants that print without the time and date stamps, and the automatic newline?
谢谢.现在,使用以下代码,我可以打印NSString,cString或对象:
Thanks. Now with following code, I can print NSString, cString, or objects:
#import <Foundation/Foundation.h>
#import <stdio.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *s = @"Hello, World!";
NSDate *today = [NSDate date];
NSLog(@"%@", s);
printf("%s at %s", [s UTF8String], [[today description] UTF8String]);
[pool drain];
return 0;
}
答
使用printf()
代替NSLog()