如何在 iPhone SDK 中添加 NSDebug.h 和使用 NSZombie [英] How to add NSDebug.h and use NSZombie in iPhone SDK

查看:43
本文介绍了如何在 iPhone SDK 中添加 NSDebug.h 和使用 NSZombie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的 iPhone 应用启用 NSZombies.

I want to enable NSZombies for my iPhone app.

我已经在网上阅读了几篇文章,但我仍然不确定确切的程序.

I have read several articles online and I am still unsure of the exact procedure.

我知道我必须设置环境变量,我已经完成了:

I know I have to set the Environment Variables, which I have done:

NSZombieEnabled = YES
NSDebugEnabled = YES
NSDeallocateZombies = NO

我想(我不确定),我必须导入 NSDebug.h.当我在我的项目中检查 Foundation Framework 的 headers 时,没有 NSDebug.h.

I think (I'm not sure), I have to import NSDebug.h. When I check the headers of the Foundation Framework in my project, there is no NSDebug.h.

经过一番研究,我在 iPhoneSimulator Foundation Framework 中找到了它们.因此(我不确定这是否正确),我将 iPhoneSimualtor Foundation Framework 导入到我的项目中.我注意到文件 STILL 没有显示在项目窗口中,即使我可以在 Finder 中找到它.(这是正常行为吗?).

After some research, I found them in the iPhoneSimulator Foundation Framework. So (and I'm not sure if this is correct), I imported the iPhoneSimualtor Foundation Framework into my project. I noticed that the file STILL does not show up in the project window, even though I can locate it in the Finder.(Is this normal behavior?).

所以我打开 main 并添加:

So I opened up main and added:

#ifdef TARGET_IPHONE_SIMULATOR
#import <Foundation/NSDebug.h>
#endif

我也不确定这是否正确.在此之后,我仍然无法让 NSZombie 工作(除非我误解了它应该做什么)我期待看到NSZombie sent a release..."之类的日志.但是我什么都没看到

I am not sure if that is right either. After this I still can't get the NSZombie to work (unless I have misunderstood what it is supposed to do) I am expecting to see a log of " NSZombie sent a release... " or something. But I don't see anything

我敢肯定我只是没有做对,我们将不胜感激.谢谢

I'm sure I'm just not doing this right, a good step by step would be appreciated. Thanks

另外值得注意的是,我还启用了:

Also of note, I have also enabled:

NSMallocStacklLogging = YES
MallocStackLoggingNoCompact = YES

推荐答案

您不必包含 NSDebug.h 或导入任何特殊框架来使用 NSZombies.基本上,在您的环境变量中打开它们,然后,如果您尝试向解除分配的对象发送消息,那么您将在控制台中看到以下内容:

You don't have to include NSDebug.h or import any special frameworks to use NSZombies. Basically, turn 'em on in your environment variables, and then, if you attempt to message a dealloc'd object, THEN you'll see something in your console, along the lines of:

2009-02-10 21:17:08.546 MyApp[16926:20b] *** -[CFString _cfTypeID]:消息发送到释放实例 0x4babc0

这篇关于如何在 iPhone SDK 中添加 NSDebug.h 和使用 NSZombie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆