正常情况下,打印的时候字典里的中文会显示成unicode格式,如下所示
给字典建一个扩展,然后在.m文件中加入下面的代码,打印的时候就会直接显示中文了
- (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;
}