Nsassert:
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 following describes Nsparameterassert
assertion evaluates a condition if the condition is False to invoke the breakpoint handle of the current thread. Each thread has its own breakpoint handle, which is an object of the Nsasserttionhandler class. When invoked, the assertion handle prints an error message that contains the method name, class name, or function name. Then, it throws a Nsinternalinconsistencyexception exception.
assertions evaluate a condition and, if the condition evaluates to False, call the assertion handler for the current T Hread, passing it a format string and a variable number of arguments. Each of the thread has its own assertion handler, which are an object of Classnsassertionhandler. When invoked, an assertion handler prints a error message that includes method and class names (or the function name). It then raises annsinternalinconsistencyexception exception.
This macro is used to confirm the validity of a objective-c method. Simply provide the parameters as a condition on the line. The macro evaluates this parameter and, if False, prints an error log message 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 a error message that includes the parameter and then raise s an exception.
If you define a preprocessing macro, the Ns_block_assertions assertion is forbidden. All the breakpoint macros return void.
Assertions is disabled if the preprocessor macro ns_block_assertions is defined. All assertion macros return void.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Using the Nsassert () and Nsparameterassert Debug Programs