打印字典和数组中的中文字符

来源:互联网 发布:mindmapping 软件 编辑:程序博客网 时间:2024/05/22 09:42

#import <Foundation/Foundation.h>


@interface NSArray (Log)


@end


@interface NSDictionary (Log)


@end


#import "NSArray+Log.h"


@implementation NSArray (Log)


- (NSString *)descriptionWithLocale:(id)locale

{

    NSMutableString *strM = [NSMutableStringstringWithString:@"(\n"];

    

    [self enumerateObjectsUsingBlock:^(id obj,NSUInteger idx, BOOL *stop) {

        [strM appendFormat:@"\t%@,\n", obj];

    }];

    

    [strM appendString:@")"];

    

    return strM;

}


@end


@implementation NSDictionary (Log)


- (NSString *)descriptionWithLocale:(id)locale

{

    NSMutableString *strM = [NSMutableStringstringWithString:@"{\n"];

    

    [selfenumerateKeysAndObjectsUsingBlock:^(id key,id obj, BOOL *stop) {

        [strM appendFormat:@"\t%@ = %@;\n", key, obj];

    }];

    

    [strM appendString:@"}\n"];

    

    return strM;

}


@end


0 0
原创粉丝点击