iOS Developer Library

Developer

Foundation Framework Reference NSAssertionHandler Class Reference

Options
Deployment Target:

On This Page
Language:

NSAssertionHandler

NSAssertionHandler objects are automatically created to handle false assertions. Assertion macros, such as NSAssert and NSCAssert, are used to evaluate a condition, and, if the condition evaluates to false, the macros pass a string to an NSAssertionHandler object describing the failure. Each thread has its own NSAssertionHandler object. When invoked, an assertion handler prints an error message that includes the method and class (or function) containing the assertion and raises an NSInternalInconsistencyException. More...

Inheritance


Conforms To


Import Statement


import Foundation @import Foundation;

Availability


Available in iOS 2.0 and later.
  • Returns the NSAssertionHandler object associated with the current thread.

    Declaration

    Swift

    class func currentHandler() -> NSAssertionHandler

    Objective-C

    + (NSAssertionHandler *)currentHandler

    Return Value

    The NSAssertionHandler object associated with the current thread.

    Discussion

    If no assertion handler is associated with the current thread, this method creates one and assigns it to the thread.

    Import Statement

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • Logs (using NSLog) an error message that includes the name of the function, the name of the file, and the line number.

    Declaration

    Objective-C

    - (void)handleFailureInFunction:(NSString *)functionName file:(NSString *)object lineNumber:(NSInteger)fileName description:(NSString *)line, format,...

    Parameters

    functionName

    The function that failed.

    object

    The object that failed.

    fileName

    The name of the source file.

    line

    The line in which the failure occurred.

    format,...

    A format string followed by a comma-separated list of arguments to substitute into the format string. See Formatting String Objects in String Programming Guide for more information.

    Discussion

    Raises NSInternalInconsistencyException.

    Import Statement

    Availability

    Available in iOS 2.0 and later.

  • Logs (using NSLog) an error message that includes the name of the method that failed, the class name of the object, the name of the source file, and the line number.

    Declaration

    Objective-C

    - (void)handleFailureInMethod:(SEL)selector object:(id)object file:(NSString *)fileName lineNumber:(NSInteger)line description:(NSString *)format, ...

    Parameters

    selector

    The selector for the method that failed

    object

    The object that failed.

    fileName

    The name of the source file.

    line

    The line in which the failure occurred.

    format,...

    A format string followed by a comma-separated list of arguments to substitute into the format string. See Formatting String Objects in String Programming Guide for more information.

    Discussion

    Raises NSInternalInconsistencyException.

    Import Statement

    Availability

    Available in iOS 2.0 and later.