Precautions for intvalue in oC

Source: Internet
Author: User

In the program, I found a problem and wrote an example, as shown below:

Nsdictionary * dict = [[nsdictionary alloc] init];
Nsstring * STR = [dict objectforkey: @ "key"];
Nslog (@ "% d", [STR intvalue]);

There is an empty dictionary, and then the corresponding value of a non-existent key is obtained from it, received with a string, and converted to the int type with intvalue. The final value obtained is

After getting depressed for a while, I found that returns 0 if the specified ER doesn't begin with a valid decimal text representation of a number.

Suddenly, it means that if the receiver of the message (the STR In the OC) does not start with a valid decimal symbol, 0 is returned.

Bugs discovered and corrected before they can grow

Precautions for intvalue in oC

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.