Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
499 views
in Technique[技术] by (71.8m points)

cocoa - How to add NSDebug.h and use NSZombie in iPhone SDK

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

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.

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?).

So I opened up main and added:

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

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Are you setting the environment variable correctly? The step by step guide is

  1. Double-click an executable in the Executables group of your Xcode project.
  2. Click the Arguments tab.
  3. In the "Variables to be set in the environment:" section, make a variable called "NSZombieEnabled" and set its value to "YES".

You don't need to #import NSDebug.h


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...