【发布时间】:2012-06-25 13:39:02
【问题描述】:
(我是可可初学者并且)我想知道为什么我们应该这样做:
NSLog(@"this is the variable value: %d",variable);
不是这样的:
[NSLog outputThis:@"this is the variable value: %d" param:variable];
【问题讨论】:
-
因为第二个语句在
NSLog对象上调用outputThis:param:方法。NSLog只是 Cocoa 框架中的一个函数。 -
是的,但它可能是类 NSLog 的类方法,例如 [NSString stringWithString:@"this is a string"]; ?
-
NSLog 不像类“听起来”。 NSLogger 将是类名的更好选择。现在它只是一个动作。
-
因为第二个看起来很糟糕,我们应该为任何看起来更像 C 的东西感到幸运;)
标签: objective-c cocoa nslog