Tuesday, December 13, 2011

iOS底下幾個NS Debug用的旗標

Screen Shot 2011 12 13 at 11 06 16 AM

首先,先Edit Scheme叫出下面這個畫面

Debug Arguments

 

這些Enviroment Varibles分別代表這些意思 :

 

NSZombieEnabled : 除錯BAD_ACCESS_ERROR用的,可以追蹤過度retain的時候的一些多於資訊

 

MallocStackLogging : 可以enable一些unhandled exception的call stack資訊。

 

NSDebugEnabled :設定除錯旗標,可以讓你在程式裡面判斷,比方說

#include <unistd.h>

int main (int argc, char ** argv, char ** envp)
{
#ifdef DEBUGENVIRON
 
if (!getenv("NSDebugEnabled"))
 
{
    setenv
("NSDebugEnabled","1",1);
   
... set the other variables ...
   
// Maybe this will complain about an autorelease pool.
   
char * executablePath = [[[NSBundle mainBundle] executablePath] filesystemRepresentation];
    execve
(executablePath, argv, environ); abort();
 
}
#endif
 
... do what you normally do in main() ...
}

但是老實講除此之外我也不知道他能幹嗎
Ref : 

http://stackoverflow.com/questions/3816136/condtional-environment-varialbes-in-xcode

http://www.yifeiyang.net/iphone-development-skills-of-debugging-articles-3-crash-after-debugging-skills-program/