ftp.nice.ch/peanuts/GeneralData/Documents/openstep/OpenStepSpec_rtf.tar.gz#/OpenStepSpec_rtf/FoundationKit/Classes/NSAssertionHandler.rtf

This is NSAssertionHandler.rtf in view mode; [Download] [Up]

paperh18648 margl-907 margr0 margt0 margb0 fi0 ri0 ql sb0 f1 fs24 Copyright f3 'e3f1 1994 by NeXT Computer, Inc.  All Rights Reserved.

s4 li100 fi0 ri1007 ql f0 b fs36 fs100 
fs36 NSAssertionHandler 
pard s11 li2872 fi-2771 ri1007 ql tx2872 f1 b0 fs28 fs48 
fs28 f0 b fs24 Inherits From:tab b0 fs28 f1 NSObject
fs20 
fs28 s6 f0 b fs24 Conforms To:tab b0 fs28 f1 NSObject (NSObject)
fs20 
fs28 s7 f0 b fs24 Declared In:tab b0 fs28 f1 Foundation/NSExceptions.h 
fs20 
fs28 pard s16 li100 fi0 ri1007 ql f0 b fs28 fs20 
fs28 Class Description
fs14 
fs28 pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 b0 fs2 
fs28 An i assertioni0  is a statement about conditions during the execution of program code, such as the relationship between variables, the state of a boolean variable, the value of an expression, and so on. If the statement about the conditions proves false, the assertion is said to have failed, and usually some action must be taken to report the failed assertion. Application programmers wishing to provide more detailed control over assertion failures than provided by the macros defined below would use the methods of NSAssertionHandler to report assertion failures.
fs16 
fs28 NSAssertionHandler provides a mechanism whereby each distinct thread of execution can have a separate handler to deal with failed assertions in code. The i fileNamei0  and i linei0  arguments to the methods described below can be obtained by using the f2 b __FILE__f1 b0  and f2 b __LINE__f1 b0  macros that are pre-defined in the C pre-processor.
fs16 
fs28 The b fs28 Foundation/NSExceptions.hb0 fs28  header file contains a collection of macros that can be used to state assertions within methods, and contains a parallel collection of macros that can be used to state assertions within regular C functions. If the condition tested in any of these macros fails, the current assertion handler is invoked with one of the methods defined below, depending on whether the macro is one of the NSAssertN or one of the NSCAssertN macros. Separate macros have from 1 to 5 arguments. Macros for dealing with assertion failures within methods are:
fs16 
fs28 pard s5 li1231 fi0 ri1007 ql f2 fs20 NSAssert1(i conditioni0 , i descriptioni0 , i argumenti0 1);
NSAssert2(i conditioni0 , i descriptioni0 , i argumenti0 1, i argumenti0 2);
NSAssert3(i conditioni0 , i descriptioni0 , i argumenti0 1, i argumenti0 2, i argumenti0 3);
NSAssert4(i conditioni0 , i descriptioni0 , i argumenti0 1, i argumenti0 2, i argumenti0 3, i argumenti0 4);
NSAssert5(i conditioni0 , i descriptioni0 , i argumenti0 1, i argumenti0 2, i argumenti0 3, i argumenti0 4, i argumenti0 5);
pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 fs28 fs16 
fs28 In each case, i conditioni0  is the statement to be tested (for example, b index < lengthb0 ), i descriptioni0  is a description of the reason for the failure (in the form of a printf-style format NSString), and each i argi0 N is an argument to be formatted according to the i descriptioni0  string.
fs16 
fs28 The parallel set of macros for dealing with failed assertions from within C functions have names of the form NSCAssertN instead of NSAssertN. The arguments are otherwise the same as the NSAssertN macros.
fs16 
fs28 pard s16 li100 fi0 ri1007 ql f0 b fs24 
fs28 Getting the Current Handler 
fs14 
fs28 pard s8 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 
fs28 fi-6552 + (NSAssertionHandler *)b currentHandlerb0 tab Returns the assertion handler for the current thread.
pard s16 li100 fi0 ri1007 ql f0 b fs48 
fs28 Handling Failures
fs14 
fs28 pard s8 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 
fs28 fi-6552 {f3 -} (void)b handleFailureInFunction:b0 (NSString *)i functionName
s9 li7030 fi-6553 fi-5796 i0 b file:b0 (NSString *)i fileNamei0 tab Logs an error message that includes i functionNamei0 ;
b lineNumber:b0 (int)i linei0 tab tab the sourcei  i0 file i fileNamei0  and the i linei0  number where
b description:b0 (NSString *)i format,...i0 tab tab the failure occured; and a short description of the
tab tab failure, described by i formati0 . It then raises an NSInternalInconsistencyException.
s8 li7029 fi-5794 fi-6552 fs16 
fs28 fi-6552 {f3 -} (void)b handleFailureInMethod:b0 (SEL)i selectori0 tab Logs an error message that includes the method (i selectori0 )
s9 li7030 fi-6553 fi-5796 b object:b0 (id)i objecti0 tab tab and i objecti0  associated with the failure; 
b file:b0 (NSString *)i fileNamei0 tab tab the source file i fileNamei0  and
b lineNumber:b0 (int)i linei0 tab tab i linei0  number in that file where the failure occured;
b description:b0 (NSString *)i format,...i0 tab tab and a short description of the failure, described by i formati0 . It then raises an NSInternalInconsistencyException.
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.