How to define a macro globally in Objective-C?

2020-02-12 09:42发布

问题:

I want to define a macro globally. I want to override NSLocalizedString() throughout my whole project. Is that possible and how do I do it?

回答1:

Declare the macro in the #ifdef __OBJC__ section of your AppName-Prefix.pch.



回答2:

You define your macro in some header file. You place this header file in *.pch file (prefix header file). Search for "prefix" in build settings for your target. Make sure your *.pch file is used.