DekGenius.com
[ Team LiB ] Previous Section Next Section

10.1 Assertions

The assertion macros are used within Objective-C methods or C functions to check a condition, and generate an assertion failure if the condition is false. The NSAssert macros are used within Objective-C methods, while the NSCAssert macros are used within C functions. The assertion macros work with a thread's assertion handler, which is an instance of the class NSAssertionHandler. When an assertion is generated the assertion handler will print an error message with the name of the method and class or function in which the assertion failure occurred. The description strings take printf style formatting.

NSAssert

NSAssert(condition, NSString *description)

NSAssert1 through NSAssert5

NSAssert1(condition, NSString *description, arg1)

NSAssert2(condition, NSString *description, arg1, arg2)

NSAssert3(condition, NSString *description, arg1, arg2, arg3)

NSAssert4(condition, NSString *description, arg1, arg2, arg3, arg4)

NSAssert5(condition, NSString *description, arg1, arg2, arg3, arg4, arg5)

NSCAssert

NSCAssert(condition, NSString *description)

NSCAssert1 through NSCAssert5

NSCAssert1(condition, NSString *description, arg1)

NSCAssert2(condition, NSString *description, arg1, arg2)

NSCAssert3(condition, NSString *description, arg1, arg2, arg3)

NSCAssert4(condition, NSString *description, arg1, arg2, arg3, arg4)

NSCAssert5(condition, NSString *description, arg1, arg2, arg3, arg4, arg5)

NSCParameterAssert

NSCParameterAssert(condition)

NSParameterAssert

NSParameterAssert(condition)

    [ Team LiB ] Previous Section Next Section