Setting a flag in compiler for NSLog not to show

后端 未结 7 1671
野趣味
野趣味 2021-01-21 18:55

Is there any particular flag which can be set to not display NSLog output in either debug or release?

Thanks.

7条回答
  •  感动是毒
    2021-01-21 19:19

    Generally, people write their own macro -- something like DebugLog -- for logs to be "compiled out":

    #undef DebugLog
    #ifdef DEBUG_MODE
    #define DebugLog( s, ... ) NSLog( @"%@", [NSString stringWithFormat:(s), ##__VA_ARGS] )
    #else
    #define DebugLog( s, ... )
    #endif
    

提交回复
热议问题