Use of Nsassert

Source: Internet
Author: User
Apple defines such a macro in Foundation.framework: #define NSASSERT (condition, desc, ...)

Nsassert () is just a macro that is used for bugs in the development phase of the debugger, by passing conditional expressions for Nsassert () to determine if a bug is true, to satisfy a conditional return truth, to run a program, to throw an exception if a false value is returned, and to customize the description of the exception. Nsassert () is defined in this way:

#define NSASSERT (condition, desc)

condition is a conditional expression, with a value of Yes or No;desc as an exception, usually nsstring. When the program continues to run when Conditon is yes, exception information with desc description is thrown when no. Nsassert () can appear at any location in the program.

The first argument is a condition, and if False, throws an exception, showing the information described by the second argument. For example Nsassert (2>=4.4, @ "2>=4.4 is false!"); Running in debug mode terminates the program and throws the following exception: 2016-06-14 09:24:16.618 testassertion[825:c07] * * * terminating app due to uncaught exception ' Nsinternalinconsistencyexception ', Reason: ' 2>=4.4 is false! ' 2016-06-14 13:58:25.132 demoforxib[13512:1550607] * * * Assertion failure in-[viewcontroller click:],/users/mac/ Desktop/demoforxib/demoforxib/viewcontroller.m:123 runs in release mode without terminating the program without throwing an exception. This facilitates the commissioning of the program.

Use of Nsassert

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.