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


 

On Oct 19, 2017, at 12:11 PM, Alex Zavatone <zav@...> wrote:

I understand that a .pch is now a “bad idea”. OK. What do we do instead? Why?
Wait, what? I never got the memo on this.

Is it good practice to create one constants.h/m? Or is that just another way of masking a global (which is bad)?
I put constants in the headers for the classes/APIs they are used with. If you look at Cocoa headers you can see Apple does the same thing.

Also, this is a separate issue from whether to use a prefix or precompiled header. Ideally your code should be buildable without a prefix header, i.e. every source file should #import the headers it depends on. The precompiled prefix header is just to speed up builds.

—Jens

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