http://blog.csdn.net/Cloud_Pro/article/details/53391656
为NSArray添加分类
- #import "NSArray+decription.h"
- @implementation NSArray (decription)
- - (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
为NSDictionary添加分类
- #import "NSDictionary+decription.h"
- @implementation NSDictionary (decription)
- - (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