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)-
NSAssert1through 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)-
NSCAssert1throughNSCAssert5 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
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access