This question already has answers here:
In Xcode, is there a way to disable the timestamps that appear in the debugger console when calling NSLog?

(8个答案)


7年前关闭。




NSLog()是否具有不带时间和日期戳以及自动换行符打印的变体?

谢谢。现在,使用以下代码,我可以打印NSString,cString或对象:
#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()

关于objective-c - 是否可以在没有时间和日期戳以及自动换行的情况下使用NSLog()? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3487226/

10-10 22:24
查看更多