objective-c

How do I declare a debug only statement


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

#if DEBUG
{
    // etc etc
}
#endif

Solution

  • 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