zoukankan      html  css  js  c++  java
  • <OC>iPhoneNSAssert使用

    assert 是C里面的宏,用于断言。

    NSAssert 只能在OC里面使用。是assert的一个扩充。能捕获assert异常,打印一些可读的日志。而assert只是让app crash(abort).

    在debug情况下,所有NSAssert都会被执行。在release下不希望NSAssert被执行的设置方法:

    在targets种选择build,选择release。在gcc preprocessing下增加Preprocessor Macros 值为 NS_BLOCK_ASSERTIONS.

    assert宏的原型定义在<assert.h>中,其作用是如果它的条件返回错误,则终止程序执行,原型定义: 
    #include <assert.h> 
    void assert( int expression ); 
    assert的作用是现计算表达式 expression ,如果其值为假(即为0),那么它先向stderr打印一条出错信息, 
    然后通过调用 abort 来终止程序运行。

  • 相关阅读:
    405
    406
    4-1
    3-11
    3-10
    3-9
    3-8
    3-7
    3-5
    3-4
  • 原文地址:https://www.cnblogs.com/robinkey/p/2872560.html
Copyright © 2011-2022 走看看