How do I declare a debug only statement

前端 未结 4 1971
说谎
说谎 2021-01-31 02:44

In C# I can use the following code to have code which only executes during debug build, how can I do the same in Xcode?

#if DEBUG
{
    // etc etc
}
#endif
         


        
4条回答
  •  面向向阳花
    2021-01-31 03:24

    The NDEBUG symbol should be defined for you already in release mode builds

    #ifndef NDEBUG
    /* Debug only code */    
    #endif 
    

    By using NDEBUG you just avoid having to specify a -D DEBUG argument to the compiler yourself for the debug builds

提交回复
热议问题