标签:
//
// NSDictionary+DescribetionDictionary.m
// fengzi
//
// Created by 谢泽锋 on 16/5/10.
// Copyright © 2016年 xiezefeng. All rights reserved.
//
#import <Foundation/Foundation.h>
//数据字典数字打印中文显示
@implementation NSDictionary (DescribetionDictionary)
-(NSString *)descriptionWithLocale:(id)locale{
NSMutableString * string=[NSMutableString string];
//开头有个[
[string appendString:@"{\n"];
[self enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
[string appendFormat:@"\t%@",key ];
[string appendString:@":"];
[string appendFormat:@"%@,\n",obj];
}];
//结尾有个]
[string appendString:@"}"];
//查找最后一个逗号
NSRange range=[string rangeOfString:@"," options:NSBackwardsSearch];//从后往前找
if (range.location !=NSNotFound) {
[string deleteCharactersInRange:range];
}
return string;
}
@end
@implementation NSArray(Log)
-(NSString *)descriptionWithLocale:(id)locale{
NSMutableString * string=[NSMutableString string];
//开头有个[
[string appendString:@"[\n"];
[self enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[string appendFormat:@"\t%@,\n",obj];
}];
//结尾有个]
[string appendString:@"]"];
//查找最后一个逗号
NSRange range=[string rangeOfString:@"," options:NSBackwardsSearch];//从后往前找
if (range.location !=NSNotFound) {
[string deleteCharactersInRange:range];
}
return string;
}
@end
标签:
原文地址:http://www.cnblogs.com/xiezefeng/p/5477108.html