Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6006843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:35:52+00:00 2026-05-23T01:35:52+00:00

I have added some debugging code to my app which I want to call

  • 0

I have added some debugging code to my app which I want to call only when needed. I remember there is some kind of IFDEF that can be used to conditionally include code into a source file.

For example I might have something like this:

IFDEF kDebugEnabled == YES {
    // some debugging code here
}

And then this piece of code is only compiled into the binary if that kDebugEnabled is YES.

How can I do something like this?

Please note: I don’t want to use the project compiler flag settings. I just want to define a BOOL (or something that serves the purpose just as well) which is true or false and then just easily set it in my App Delegate for example. I find it hard to navigate to the project compiler settings, searching for a flag and then setting it. I know there is a Debug flag which might be of use.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:35:53+00:00Added an answer on May 23, 2026 at 1:35 am

    What you are looking for is:

    #ifdef __YOURSYMBOL__
      <conditional code>
    #endif
    

    You can programmatically define __YOURSYMBOL__ like this:

     #define __YOURSYMBOL__
    

    __YOURSYMBOL__ can be any string that makes sense to you to remember why you are including/excluding that code snippet.

    The DEBUG constant is a special preprocessor constant that the compiler defines specifically for you when the code is built for debugging, so you can simply use it:

    #ifdef DEBUG
             <conditional code>
    #endif
    

    Take into account that this is the C-preprocessor, not C, nor Objective-C that you are using, so a test like kDebugEnabled == YES (where kDebugEnabled is an Objective-C variable) is simply not possible. You can define integer values for your constants, like this:

    #define __LOG_LEVEL__ 3
    

    and then test for it:

    #if __LOG_LEVEL__ == 3
        ...
    Endif
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added some code which compiles cleanly and have just received this Windows
I Have an odd issue with some JavaScript code (again, I hate debugging JS
I have added some custom actions to our installer which is run on CE5
In list of dropdown i have added some text and i want that if
I have a page with some dynamically added buttons. If you click a button
I have a form with multiple fields that I'm validating (some with methods added
I have added some backgrounds on stage and then on top of that adding
I have added some constraints to some MySQL table fields. This seems to change
Hopefully an easy question: I have added some docs to the index, where every
i have a input tag which is non editable, but some times i need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.