有次尝试打印,发现并不能,
于是去找资料.发现一个分类,导入之后可以使用
但是不知道其中的原理是什么 有个allkey不晓得
话不多说,直接上代码,求教
#import <Foundation/Foundation.h>
@interface NSMutableDictionary (Mylog)
@end
#import "NSMutableDictionary+Mylog.h"
@implementation NSMutableDictionary (Mylog)
- (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
来个大神看看,教教 |
|