iOS Prefix.pch最佳实践 [英] iOS Prefix.pch best practices

查看:161
本文介绍了iOS Prefix.pch最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我见过许多开发人员为他们的iOS项目的Prefix.pch添加了各种便利宏。

I have seen many developers that add various convenience macros to the Prefix.pch of their iOS projects.

你建议添加什么(或不是) iOS Prefix.pch文件?你的Prefix.pch是什么样的?

What do (or don't) you recommend adding to the iOS Prefix.pch file? What does your Prefix.pch look like?

推荐答案

Ewww ...不要把宏放在.pch文件中!根据定义,.pch文件是项目特定的预编译头。它确实不应该超出项目的上下文使用,除了 #include s和 #import s。

Ewww… don't put macros in a .pch file! A .pch file is, by definition, a project specific precompiled header. It really shouldn't be used beyond the context of the project and it really shouldn't contain anything but #includes and #imports.

如果您有一些宏,并且想要在标题之间共享,那么请将它们粘贴在自己的头文件中 - Common.h 或其他 - 和 #include 在.pch的开头。

If you have some macros and such that you want to share between headers, then stick 'em in a header file of their own — Common.h or whatever — and #include that at the beginning of the .pch.

这篇关于iOS Prefix.pch最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆