1,新建一个乱码文件的category分类文件
2.然后堆descriptionWithLocale函数进行重写。
例如:
-
-
@interface NSArray (chinese)
-
//local是你定义的数组同下
-
- (NSString *)descriptionWithLocale:(id)locale;
-
-
@end
-
-
@interface NSDictionary (chinese)
-
-
- (NSString *)descriptionWithLocale:(id)locale;
-
-
@end
-
-
@implementation NSArray (chinese)
-
-
- (NSString *)descriptionWithLocale:(id)locale
-
{
-
-
-
NSMutableString *strM = [NSMutableString string];
-
[strM appendString:@"(\n"];
-
-
for (id obj in self) {
-
[strM appendFormat:@"\t\t%@,\n", obj];
-
}
-
[strM appendString:@")"];
-
-
return strM;
-
}
-
-
-
-
@end
-
-
-
@implementation NSDictionary (chinese)
-
-
- (NSString *)descriptionWithLocale:(id)locale
-
{
-
-
NSMutableString *strM = [NSMutableString string];
-
[strM appendString:@"{\n"];
-
-
for (id obj in [self allKeys]) {
-
[strM appendFormat:@"\t\t%@,", obj];
-
-
[strM appendFormat:@"%@\n", self[obj]];
-
}
-
-
[strM appendString:@"}"];
-
-
return strM;
-
}
-
-
-
@end
-
版权声明:本文为博主原创文章,未经博主允许不得转载。
OC中NSMutableArray 和NSMutableDictionary 中打印乱码问题
原文:http://blog.csdn.net/u012989536/article/details/47842423