Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
184 views
in Technique[技术] by (71.8m points)

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 Xcode?

#if DEBUG
{
    // etc etc
}
#endif
question from:https://stackoverflow.com/questions/479531/how-do-i-declare-a-debug-only-statement

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...