About Nslocalizedstring (@ "Foo%@", nil)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.