zoukankan      html  css  js  c++  java
  • NSAssert

    首先,NSAssert 是 foundation.framework 框架中的一个宏定义,作为断点检查的条件信息。如果给他一个 false 条件,会生成一个断点检查。

    NSAssert

    Generates an assertion if a given condition is false.

    Declaration 声明

    OBJECTIVE-C

    #define NSAssert(condition, desc, ...)

    Parameters 参数

    condition

    An expression that evaluates to YES or NO.

      值为 YES 或 NO 的表达式

    desc

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

     

    ...

    The arguments displayed in the desc string.

    Discussion

    The NSAssert 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 descas the description string.

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

    Assertions are disabled if the preprocessor macro NS_BLOCK_ASSERTIONS is defined.

    IMPORTANT

    Do not call functions with side effects in the condition parameter of this macro. The condition parameter is not evaluated when assertions are disabled, so if you call functions with side effects, those functions may never get called when you build the project in a non-debug configuration.

    NOTE

    Not all release configurations disable assertions by default.

     
  • 相关阅读:
    自己设计的SSO登录流程图
    Java泛型:泛型类、泛型接口和泛型方法
    Java中泛型的各种使用
    Java总结篇系列:Java泛型
    java生成MD5校验码
    Android SQLite数据库之事务的学习
    Android SQLite详解
    android删除表和清空表
    Android 软键盘自动弹出和关闭
    java中表示二进制、八进制、十进制、十六进制
  • 原文地址:https://www.cnblogs.com/ablettchen/p/4102942.html
Copyright © 2011-2022 走看看