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

查看:26
本文介绍了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 文件是项目特定的预编译头文件.它真的不应该在项目的上下文之外使用,它真的不应该包含除了 #includes 和 #imports 之外的任何东西.

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天全站免登陆