Macro

NSAssert2

Generates an assertion if a given condition is false.

Declaration

#define NSAssert2(condition, desc, arg1, arg2)

Parameters

condition

An expression that evaluates to YES or NO.

desc

An NSString object that contains a printf-style string containing an error message describing the failure condition and placeholders for two arguments.

arg1

An argument to be inserted, in place, into desc.

arg2

An argument to be inserted, in place, into desc.

Discussion

The NSAssert2 macro evaluates the condition and serves as a front end to the assertion handler.

Each thread has its own assertion handler, which is an object of class NSAssertionHandler. When invoked, an assertion handler prints an error message that includes the method and class names (or the function name). It then raises an NSInternalInconsistencyException exception. If condition evaluates to NO, the macro invokes handleFailureInMethod:object:file:lineNumber:description: on the assertion handler for the current thread, passing desc as the description string and arg1 and arg2 as substitution variables.

This macro should be used only within Objective-C methods.

Assertions are disabled if the preprocessor macro NS_BLOCK_ASSERTIONS is defined or the ENABLE_NS_ASSERTIONS Xcode build setting is disabled.

See Also

Assertions

NSAssertionHandler

An object that logs an assertion to the console.

NSAssert

Generates an assertion if a given condition is false.

NSAssert1

Generates an assertion if a given condition is false.

NSAssert3

Generates an assertion if a given condition is false.

NSAssert4

Generates an assertion if a given condition is false.

NSAssert5

Generates an assertion if a given condition is false.

NSCAssert

Generates an assertion if the given condition is false.

NSCAssert1

Generates an assertion if a given condition is false.

NSCAssert2

Generates an assertion if a given condition is false.

NSCAssert3

Generates an assertion if a given condition is false.

NSCAssert4

Generates an assertion if a given condition is false.

NSCAssert5

Generates an assertion if a given condition is false.

NSCParameterAssert

Evaluates the specified parameter.

NSParameterAssert

Validates the specified parameter.