我对 NSLocalizedString 的所有调用都将 nil 作为第二个参数,因为我不使用任何注释。但我讨厌重复自己。现在我问自己是否可以定义一个像 LSSTRING(str) 这样调用 NSLocalizedString(str, nil) 的宏,如果可以的话怎么做?
问问题
3222 次
2 回答
10
你可以。将以下宏添加到您的预编译头文件中。即,在 {ProjectName}-Prefix.pch 文件中
#define LSSTRING(str) NSLocalizedString(str, nil)
于 2011-10-25T11:41:37.260 回答
2
我正在使用
#define _(format, ...) [[NSBundle mainBundle] localizedStringForKey: [NSString stringWithFormat:@"%@", [NSString stringWithFormat:format, ##__VA_ARGS__]] value:@"" table:nil]
于 2011-10-25T11:44:08.547 回答