Question

I have NSZombieEnabled to NO in my arguments.

I am checking to see if it is enabled:

if(getenv("NSZombieEnabled") || getenv("NSAutoreleaseFreedObjectCheckEnabled")) 
    {
        NSLog(@"NSZombieEnabled/NSAutoreleaseFreedObjectCheckEnabled enabled!");
    }

My debugger says it is still enabled. Why?

Was it helpful?

Solution

try to uncheck it. If it has no checkmark in front it shouldn't be passed to the application.

It should be off when you set the value to NO, but getenv("NSZombieEnabled") will return "NO". Which is not a boolean NO but a cstring "NO". So the if condition will be true anyway.

OTHER TIPS

I know this question is old, but for people’s reference, you can use this technique for many debug flags:

extern BOOL NSZombieEnabled;
if (NSZombieEnabled)
    ...

If it links, it will work.

Here's a suggestion which checks for both the existence of the env variable and the correct value.

char* szZombie = getenv("NSZombieEnabled");
if (szZombie && 0 == strcasecmp(szZombie, "YES"))
{
    NSLog(@"NSZombieEnabled enabled!");        
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top