[Cocoa] 定制 Prefix.pch文件
2011-10-16 20:58
281 查看
[Cocoa] 定制 Prefix.pch文件
罗朝辉(http://blog.csdn.net/kesalin/)
CC许可,转载请注明出处
扩展名 pch 表示 “precompliled header”,即预编译头文件,prefix.pch 为 XCode 工程默认生成的预编译头文件,在其中我们可以定制一些全局的宏,以方便开发。
下面贴一段来自
Cocoa Is My Girlfriend 定制的宏:
详细解说请阅读原文,在这里我只说明其用法:
1,如果是 debug 模式下,需要在编译选项 Preprocessor
Macros 中设置 DEBUG 宏;
2,DLog 相当于 NSLog,但只在 debug 模式下有效;在
release 模式下,它什么也不做;
3,ALog 是 Assert Log 的简写,在 debug 模式下,相当于强制
assert;在 release 模式下,相当于 NSLog;
4,ZAssert 是带有条件判断的 ALog;
参考资料:
My current Prefix.pch file
罗朝辉(http://blog.csdn.net/kesalin/)
CC许可,转载请注明出处
扩展名 pch 表示 “precompliled header”,即预编译头文件,prefix.pch 为 XCode 工程默认生成的预编译头文件,在其中我们可以定制一些全局的宏,以方便开发。
下面贴一段来自
Cocoa Is My Girlfriend 定制的宏:
#ifdef DEBUG #define DLog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__]) #define ALog(...) [[NSAssertionHandler currentHandler] handleFailureInFunction:[NSString stringWithCString:__PRETTY_FUNCTION__ encoding:NSUTF8StringEncoding] file:[NSString stringWithCString:__FILE__ encoding:NSUTF8StringEncoding] lineNumber:__LINE__ description:__VA_ARGS__] #else #define DLog(...) do { } while (0) #ifndef NS_BLOCK_ASSERTIONS #define NS_BLOCK_ASSERTIONS #endif #define ALog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__]) #endif #define ZAssert(condition, ...) do { if (!(condition)) { ALog(__VA_ARGS__); }} while(0)
详细解说请阅读原文,在这里我只说明其用法:
1,如果是 debug 模式下,需要在编译选项 Preprocessor
Macros 中设置 DEBUG 宏;
2,DLog 相当于 NSLog,但只在 debug 模式下有效;在
release 模式下,它什么也不做;
3,ALog 是 Assert Log 的简写,在 debug 模式下,相当于强制
assert;在 release 模式下,相当于 NSLog;
4,ZAssert 是带有条件判断的 ALog;
参考资料:
My current Prefix.pch file
相关文章推荐
- [Cocoa]XCode中定制Prefix.pch文件
- XCode6 生成prefix.pch文件
- XCode6 生成prefix.pch文件
- 关于<AppName>-Prefix.pch文件的科幻用法
- 【iOS 基础控件 - 10 】iOS 项目中的文件 - projectname-Info.plist - projectname-Prefix.pch
- Cocos2d-x Prefix.pch 文件的用法
- IOS 之 Prefix.pch 预编译文件详解
- Info.plist与Prefix.pch修改文件位置遇到的问题及解决方法
- [持续更新] Cocos2d-x Prefix.pch 文件的用法
- XCode6 生成prefix.pch文件
- Precompile Prefix file(.pch文件)
- 关于<AppName>-Prefix.pch文件的科幻用法
- 开源中国iOS客户端学习——(一)Prefix.pch文件
- Prefix.pch文件的作用
- 关于<AppName>-Prefix.pch文件的科幻用法
- CocoaPods+PrefixHeader.pch+Const
- IOS-Prefix.pch 文件不起作用
- prefix pch 中引用cocoapods 中的头文件失败
- 在Xcode6中添加prefix.pch文件
- ios开发 <AppName>-Prefix.pch文件的用法详解