因为在一个OC工程中,可能包含.m、.mm、.c、.cpp四类编译文件,这四类文件均会引用.pch预编译头。在编译.c、.cpp时,因为语法不兼容OC,所以预编译头中不能包含objc代码。
But因为.pch是2类源文件共用的,所以在pch中,oc头文件要用__OBJC__包含起来。如下:
There is one additional substitution token available in Objective-C, %@, used to denote an object. At runtime, this specifier will be substituted with the result of calling either the descriptionWithLocale: method (if it exists) or the description method on the provided object. The description method is implemented by NSObject to return the class and memory address of the object, but many Cocoa and Cocoa Touch classes override it to provide more useful information. In the case of NSString, the description method simply returns the string of characters that it represents.
NSLog与printf相比,添加了%@这么一个输出格式,%@对应的对象在编译后会被替换为对descriptionWithLocal方法的调用,如果此方法不存在,则替换为description方法的调用
Example of logging the current method and line number. Paste it into your project, and see what it prints!
Preprocessor macros and for logging in C/C++/Objective-C.