您的位置:首页 > 其它

Xcode log输出中文

2016-07-26 17:47 405 查看
直接添加一个分类输出中文 在PrefixHeader.pch import即可。

//NSArray+Log.h
#import <Foundation/Foundation.h>
@interface NSArray (Log)
- (NSString *)descriptionWithLocale:(id)locale;
@end
@interface NSDictionary (Log)
- (NSString *)descriptionWithLocale:(id)locale;
@end

//NSArray+Log.m
#import "NSArray+Log.h"
@implementation NSArray (Log)
- (NSString *)descriptionWithLocale:(id)locale
{
NSMutableString *strM = [NSMutableString stringWithString:@"(\n"];
for (id obj in self) {
[strM appendFormat:@"\t%@,\n", obj];
}
[strM appendString:@")\n"];
return strM;
}
@end
@implementation NSDictionary (Log)
- (NSString *)descriptionWithLocale:(id)locale
{
NSMutableString *strM = [NSMutableString stringWithString:@"{\n"];
[self enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
[strM appendFormat:@"\t%@ = %@;\n", key, obj];
}];
[strM appendString:@"}\n"];
return strM;
}
@end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  xcode