NSZombieEnabled 不会关闭

发布于 2024-09-28 06:21:35 字数 285 浏览 1 评论 0原文

我在我的论点中将 NSZombieEnabled 设置为 NO。

我正在检查它是否已启用:

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

我的调试器说它仍然启用。为什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

染火枫林 2024-10-05 06:21:35

尝试取消选中它。如果它前面没有复选标记,则不应将其传递给应用程序。

当您将值设置为 NO 时,它应该关闭,但 getenv("NSZombieEnabled") 将返回“NO”。这不是一个布尔NO而是一个cstring“NO”。所以 if 条件无论如何都是 true。

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.

戏剧牡丹亭 2024-10-05 06:21:35

我知道这个问题很旧,但是为了人们的参考,您可以将这种技术用于许多调试标志:

extern BOOL NSZombieEnabled;
if (NSZombieEnabled)
    ...

如果它链接,它将起作用。

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.

桜花祭 2024-10-05 06:21:35

这是一个检查 env 变量是否存在以及正确值的建议。

char* szZombie = getenv("NSZombieEnabled");
if (szZombie && 0 == strcasecmp(szZombie, "YES"))
{
    NSLog(@"NSZombieEnabled enabled!");        
}

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!");        
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文