IOS中调试的辅助宏 NSAssert

NSAssert函数:

1 NSAssert(condition, desc, ...);

1. condition:条件,如果条件满足则程序正常之行,如果条件不满足则程序崩溃,奔溃的信息可以由后面的desc来打印出来:

    实例如下:

    NSInteger age = 10;
    NSAssert(age == 01, @"the condition is not right -%s--%s---%d",__FILE__,__FUNCTION__,__LINE__);

 这时打印出来的信息为:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unable to find archive in bundle.-/Users/robot/Desktop/BornToTry/BornToTry/ViewController.m---[ViewController viewDidLoad]---32'

posted @ 2015-12-19 15:12  击水湘江  阅读(209)  评论(0编辑  收藏  举报