My application has several hundred points of localisation, some of which can be reused many times. To prevent from hunting and pecking through code to find occurrences of a particular NSLocalizedString
, I create a macro for each in a header file using the #define
preprocessor directive. For example:
#define kLocFirstString NSLocalizedString(@"Default Text", @"Comment")
#define kLocSecondString NSLocalizedString(@"More Text", @"Another comment")
...
When I want to refer to a particular string, I do so by its macro name. This method has been working nicely for me, but I'm concerned that such blatant abuse of #define
is frowned upon. From the standpoint of "correctness", should I just inline each NSLocalizedString
with the code, or is there another method (extern NSString *aString;
perhaps?) that I can use to collect the declarations in one place?