iphonecool
iphonecool

Reputation: 97

How to Restrict NSLog in Distribution and Release Mode -iPhone

I want to Enable the NSLog only in Debug Mode. I need to restrict NSLog in Distribution and Release mode.

I am using the code below,

#ifdef DEBUG
#   define NSLog(...) NSLog(__VA_ARGS__);
#else 
#   define NSLog(...)
#endif

But it's not working. anyone please explain me as brief as possible. Where should i use the code in every NSLog statement or Every class or only in .PCH class..

Thanks for your consideration and Effort

Upvotes: 1

Views: 484

Answers (2)

Inder Kumar Rathore
Inder Kumar Rathore

Reputation: 39988

Put this into your .pch file

#ifndef DEBUG
#undef NSLog
#define NSLog(args, ...)
#endif

Upvotes: 1

SachinVsSachin
SachinVsSachin

Reputation: 6427

Write this to your .pch file

#ifndef DLog
#ifdef DEBUG
#define DLog(_format_, ...) NSLog(_format_, ## __VA_ARGS__)
#else
#define DLog(_format_, ...)
#endif
#endif

After this use DLog instead of NSLog to meet with your goal

Upvotes: 3

Related Questions