iOS 让Xcode打印汉字, 而不是UTF8编码

为NSArray添加分类

#import "NSArray+decription.h"

@implementation NSArray (decription)

- (NSString *)descriptionWithLocale:(id)locale
{
    NSMutableString *str = [NSMutableString stringWithFormat:@"%lu (\n", (unsigned long)self.count];
    
    for (id obj in self) {
        [str appendFormat:@"\t%@, \n", obj];
    }
    
    [str appendString:@")"];
    
    return str;
}

@end

为NSDictionary添加分类

#import "NSDictionary+decription.h"

@implementation NSDictionary (decription)

- (NSString *)descriptionWithLocale:(id)locale
{
    NSArray *allKeys = [self allKeys];
    NSMutableString *str = [[NSMutableString alloc] initWithFormat:@"{\t\n "];
    for (NSString *key in allKeys) {
        id value= self[key];
        [str appendFormat:@"\t \"%@\" = %@,\n",key, value];
    }
    [str appendString:@"}"];
    
    return str;
}

@end


你可能感兴趣的:(iOS 让Xcode打印汉字, 而不是UTF8编码)