标签:
NSLog
,但是发布时想取消这些 NSLog
NSLog(@"%s", __FUNCTION__);
ExtendNSLog
类,继承自 NSObject
ExtendNSLog.h
中删除默认代码void ExtendNSLog(const char *file, int lineNumber, const char *functionName, NSString *format, ...);
ExtendNSLog.m
中删除默认代码1 void ExtendNSLog(const char *file, int lineNumber, const char *functionName, NSString *format, ...) { 2 3 va_list ap; 4 5 va_start(ap, format); 6 7 if (![format hasSuffix: @"\n"]) { 8 format = [format stringByAppendingString: @"\n"]; 9 } 10 11 NSString *body = [[NSString alloc] initWithFormat:format arguments:ap]; 12 13 va_end(ap); 14 15 NSString *fileName = [[NSString stringWithUTF8String:file] lastPathComponent]; 16 fprintf(stderr, "(%s) (%s:%d) %s", 17 functionName, 18 [fileName UTF8String], 19 lineNumber, 20 [body UTF8String]); 21 }
PrefixHeader.pch
文件1 #ifdef __OBJC__ 2 3 #import <UIKit/UIKit.h> 4 #import <Foundation/Foundation.h> 5 6 #import "ExtendNSLog.h" 7 8 #ifdef DEBUG 9 #define NSLog(args...) ExtendNSLog(__FILE__, __LINE__, __PRETTY_FUNCTION__, args); 10 #else 11 #define NSLog(x...) 12 #endif 13 14 #endif
项目
->TARGETS
->[ProjectName]
->Build Settings
prefix header
Prefix Header
中输入 [ProjectName]/PrefixHeader.pch
如下图所示
标签:
原文地址:http://www.cnblogs.com/jiahao89/p/5069861.html