formatting strings using literal syntax

Source: Internet
Author: User

after supporting arm64, there are some problems when formatting strings, mainly related to the definition of Nsinteger:

#if __lp64__ | | (target_os_embedded &&!) Target_os_iphone) | | Target_os_win32 | | ns_build_32_like_64longlong  Nsuinteger; #else  intint  Nsuinteger; #endif

In other words, when you format a string for Nsinteger, you need to use %ld, and in the case of the three digits, %d is required.

One workaround is to force type conversions.

the other way, is to format the string after it has been converted to nsnumber* using the literal syntax.

For example:

6 ; NSLog (@ "%@", @ (value)); NSString* test = [NSString stringWithFormat:@ "%@", @ (value)];

is actually converted to nsnumber object and then formatted, the disadvantage of course is more than one boxing process , but the code is easier to write, especially in the resource file given the string of time do not need to worry about whether to use%d or% ld.

formatting strings using literal syntax

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.