Re: Objective-C: What is the current preferred method of declaring constants without a .pch?


Bernie Maier
 

Alex Zavatone:

I understand that a .pch is now a “bad idea”. OK. What do we do
instead? Why?
Pre-compiled headers are now considered to be a bad idea, yes, but although traditionally the *prefix* header was usually pre-compiled it doesn't have to be. So what I use in some of my project is a prefix header that simply isn't pre-compiled.

That said, I use it *extremely* sparingly, kind of like a more SCM-friendly place to define constants like conditional compilation flags that need to consistent across an entire build. These are often supplied as -D arguments to the compiler, and thus often live in relative obscurity amongst other project settings.

Like others, I would normally attach more specific constants to whatever they are most related to.

Join {cocoa@apple-dev.groups.io to automatically receive all group messages.