Managing several hundred occurrences of NSLocalizedString

Posted by Gordon Hughes on Stack Overflow See other posts from Stack Overflow or by Gordon Hughes
Published on 2010-04-06T17:25:11Z Indexed on 2010/04/06 20:43 UTC
Read the original article Hit count: 332

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?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c