• NSAssert和NSParameterAssert


    #if !defined(NS_BLOCK_ASSERTIONS)
    
    //NSAssert定义
    #if !defined(_NSAssertBody)
    #define NSAssert(condition, desc, ...)    
        do {                
        __PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS 
        if (__builtin_expect(!(condition), 0)) {        
                NSString *__assert_file__ = [NSString stringWithUTF8String:__FILE__]; 
                __assert_file__ = __assert_file__ ? __assert_file__ : @"<Unknown File>"; 
            [[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd 
            object:self file:__assert_file__ 
                lineNumber:__LINE__ description:(desc), ##__VA_ARGS__]; 
        }                
            __PRAGMA_POP_NO_EXTRA_ARG_WARNINGS 
        } while(0)
    #endif
    
    
    //NSCAssert定义
    #if !defined(_NSCAssertBody)
    #define NSCAssert(condition, desc, ...) 
        do {                
        __PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS 
        if (__builtin_expect(!(condition), 0)) {        
                NSString *__assert_fn__ = [NSString stringWithUTF8String:__PRETTY_FUNCTION__]; 
                __assert_fn__ = __assert_fn__ ? __assert_fn__ : @"<Unknown Function>"; 
                NSString *__assert_file__ = [NSString stringWithUTF8String:__FILE__]; 
                __assert_file__ = __assert_file__ ? __assert_file__ : @"<Unknown File>"; 
            [[NSAssertionHandler currentHandler] handleFailureInFunction:__assert_fn__ 
            file:__assert_file__ 
                lineNumber:__LINE__ description:(desc), ##__VA_ARGS__]; 
        }                
            __PRAGMA_POP_NO_EXTRA_ARG_WARNINGS 
        } while(0)
    #endif
    //NSParameterAssert定义
    #define NSParameterAssert(condition) NSAssert((condition), @"Invalid parameter not satisfying: %@", @#condition)
    //NACParameterAssert定义
    #define NSCParameterAssert(condition) NSCAssert((condition), @"Invalid parameter not satisfying: %@", @#condition)

    参看链接:https://www.jianshu.com/p/6e444981ab45

  • 相关阅读:
    Handler机制来处理子线程去更新UI线程控件
    获得某月份的天数
    listview选中没有效果
    kali或其他系统,虚拟机中不能加载镜像
    tomcat开启多个端口
    kali自定义分辨率
    Redis 安装手册
    bash检查centos服务器运行状态
    关于利用RD client远程电脑,和输入法的一些问题
    centOS下 MYSQL基本操作
  • 原文地址:https://www.cnblogs.com/chaoguo1234/p/9115814.html
Copyright © 2020-2023  润新知