Xcode log输出中文

来源:互联网 发布:中原突围 知乎 编辑:程序博客网 时间:2024/05/16 07:43

直接添加一个分类输出中文 在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
0 0
原创粉丝点击