DCMaxxx DCMaxxx - 4 months ago 11x
iOS Question

Objective-C : #define vs extern const

I know this question has been asked before, but I can't seem to find information about it in Apple's documentation; maybe some of you guys did.

A lot of Objective-C code has cross-file constants in a

file, using
Others use the approach of a
with constants and
them in the

I understand the difference, both pros and cons, but does Apple state which one to use in iOS development?


Apple's recommendation is extern:

Define constants for strings used for such purposes as notification names and dictionary keys. By using string constants, you are ensuring that the compiler verifies the proper value is specified (that is, it performs spell checking).

Admittedly they are inconsistent about this sometimes.