-
Notifications
You must be signed in to change notification settings - Fork 0
/
NSDictionary+Log.m
49 lines (36 loc) · 1.1 KB
/
NSDictionary+Log.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// NSDictionary+Log.m
//
//
// Created by apple on 13/8/10.
// Copyright (c) 2013年 潘九龙. All rights reserved.
// 字典和数组中中文的输出打印
#import <Foundation/Foundation.h>
@implementation NSDictionary (Log)
- (NSString *)descriptionWithLocale:(id)locale
{
// 1.定义字符串保存拼接结果
NSMutableString *strM = [NSMutableString string];
[strM appendFormat:@"{\n"];
// 2.遍历字典, 拼接字典中的键值对
[self enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
[strM appendFormat:@"\t%@:%@\n", key, obj];
}];
[strM appendFormat:@"}\n"];
return strM;
}
@end
@implementation NSArray (Log)
- (NSString *)descriptionWithLocale:(id)locale
{
// 1.定义字符串保存拼接结果
NSMutableString *strM = [NSMutableString string];
[strM appendFormat:@"(\n"];
// 2.遍历字典, 拼接字典中的键值对
[self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
[strM appendFormat:@"\t%@", obj];
}];
[strM appendFormat:@")\n"];
return strM;
}
@end