1, method
It's best to get a single class, defined as a class method.
All know the debug and release of iOS, so I defined a macro like this from the beginning:
#ifdef DEBUG
#define ZHHLOG (...) NSLog (__va_args__)
#else
#define ZHHLOG (...)
#endif
#define MAKECHAR (param) @ #param
Fig. h
Fig. M
How to use
2, macro
Define macros, without the trouble above, get directly into a public. h Okle.
Code:
#ifdef DEBUG
#define ZHHLOG (...) NSLog (__va_args__)
#else
#define ZHHLOG (...)
#endif
#define ZHHASSERTPARAMNOTNIL2 (param, returnvalue) \
ZHHAssert2 (param, [[NSString stringwithformat:@ #param] stringbyappendingstring:@ "parameter cannot be nil"], returnvalue)
#define ZHHASSERT2 (condition, desc, returnvalue) \
if ((condition) = = NO) {\
NSString *file = [NSString stringwithutf8string:__file__]; \
Zhhlog (@ "\ n Warning File:%@\n warning Line: line%d \ n Warning Method:%s\n Warning Description:%@", File, __line__, __function__, DESC); \
Return returnvalue; \
}
Usage:
ZHHAssertParamNotNil2 (nil, nil)
IOS Custom Warning Prompt (method + macro)--imitate MJ