Link Address: http://www.cnblogs.com/flyFreeZn/archive/2013/11/16/3427244.html
About Nslocalizedstring (@ "Foo%@", nil)
Nslocalizedstring (@ "foo%@", nil) is actually looking for a key "Foo%@" in a multilingual file, never put this and [NSString stringwithformat:@ "%@", @ "hehe "]; confused.
In particular, there is a very special situation that occurs in the open Source tool of Appirater.
For the following code
#define APPIRATER_APP_NAME @ "APP" #define Appirater_localized_message_title nslocalizedstring (@ "Rate%@", nil) # Define Appirater_message_title [NSString stringwithformat:appirater_localized_message_title, APPIRATER_APP_ NAME]
At first glance, thinking that the end result is to find the key "rate App" in a multilingual file, not really!
The result of the final Appirater_message_title is: First in the multilingual file to find the key "rate%@" text, if found, then return this text, ignoring stringwithformat inside that appirater_app_name, If you can't find it, go back to "rate App"!
Isn't it weird? This usage is too powerful and magical:)
A little more specific:
Like I do.
If you can find the key for "rate%@" in the multilingual text, string will return the text directly, that is, return nslocalizedstring (@ "Rate%@", nil)
If not found, return [NSString stringwithformat:@ "Rate%@", appirater_app_name];
About Nslocalizedstring (@ "Foo%@", nil)