新建兩個分類蓖宦,一個NSArray分類膜赃、一個NSDictionary分類.在哪用就在那里import,或者加到.pch里面全局使用。
#import "NSArray+RMArray.h"
@implementation NSArray (RMArray)
- (NSString *)descriptionWithLocale:(id)locale{//打印中文
NSMutableString *str = [NSMutableString stringWithFormat:@"%lu (\n", (unsigned long)self.count];
for (id obj in self) {
[str appendFormat:@"\t%@, \n", obj];
}
[str appendString:@")"];
return str;
}
@end
#import "NSDictionary+RMDictionary.h"
@implementation NSDictionary (RMDictionary)
- (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