What NSParameterAssert does in iOS

Source: Internet
Author: User


<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHAgY2xhc3M9 "p1"> Discuss Discussion

An assertion evaluates a condition. If the condition is false, the breakpoint handle of the current thread is called. Each thread has its own breakpoint handle, which is an object of the NSAsserttionHandler class. When called, the assertion handle prints an error message that contains the method name, class name, or function name. Then, it throws an NSInternalInconsistencyException.
Assertions evaluate a condition and, if the condition evaluates to false, call the assertion handler for the current thread, passing it a format string and a variable number of arguments. each thread has its own assertion handler, which is an object of classNSAssertionHandler. when invoked, an assertion handler prints an error message that includes des method and class names (or the function name ). it then raises anNSInternalInconsistencyException exception.

This macro is used to verify the validity of an Objective-C method. Simply provide parameters as conditions. This macro evaluates this parameter. If it is false, it prints an error log that contains the parameter and throws an exception.
This macro validates a parameter for an Objective-C method. simply provide the parameter as the condition argument. the macro evaluates the parameter and, if it is false, it logs an error message that contains des the parameter and then raises an exception.

If the pre-processing macro NS_BLOCK_ASSERTIONS asserted is defined, it will be disabled. All breakpoint macros return void.
Assertions are disabled if the preprocessor macro NS_BLOCK_ASSERTIONS is defined. All assertion macros return void.


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.