Disable NSLog

Discussion in 'iOS Programming' started by spilakalb, Oct 1, 2012.

  1. spilakalb, Oct 1, 2012
    Last edited by a moderator: Oct 1, 2012

    spilakalb macrumors member

    Joined:
    Sep 23, 2012
    #1
    I found below code for disable/enable NSLog..In which file I place this code for testing..Appdelegate /main/etc....??

    Code:
    #if !defined(DEBUG) || !(TARGET_IPHONE_SIMULATOR)
        #define NSLog(...)
    #endif
     
  2. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    This should go in your PCH file :)
    We use something called DLog, which shows you the class + method + line that called the log, really usefull in big apps, and it doesn't include at compile time neither.
     
  3. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #3
    I use this. It allows you to have NSLog() independent of DebugLog(). It goes in the pch file.

    Code:
    #ifdef DEBUG
    #define DebugLog(s, ...) NSLog(s, ##__VA_ARGS__)
    #else
    #define DebugLog(s, ...)
    #endif
    
     
  4. forum user macrumors regular

    Joined:
    Aug 28, 2008
    #4

Share This Page