Generates an assertion if the given condition is false.
- iOS 2.0+
- macOS 10.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
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 class
NSAssertion. When invoked, an assertion handler prints an error message that includes method and class names (or the function name). It then raises an
NSCAssert macro evaluates the condition and serves as a front end to the assertion handler. This macro should be used only within C functions.
NSCAssert takes no arguments other than the condition and format string.
condition must be an expression that evaluates to true or false.
description is a printf-style format string that describes the failure condition.
Assertions are disabled if the preprocessor macro
NS is defined. All assertion macros return void.