iOS 解决NSlog打印输出的的文字都是UTF-8格式
2017-06-14 14:41
344 查看
// 创建 NSDictionary 和 NSArray 的分类
Category 并添加如下代码后NSLog文字正常显示
@interface NSDictionary (DeUTF)
@end
@implementation NSDictionary (DeUTF)
- (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
//--------------------------------------
@interface NSArray (DeUTF)
@end
@implementation NSArray (DeUTF)
- (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
Category 并添加如下代码后NSLog文字正常显示
@interface NSDictionary (DeUTF)
@end
@implementation NSDictionary (DeUTF)
- (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
//--------------------------------------
@interface NSArray (DeUTF)
@end
@implementation NSArray (DeUTF)
- (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
相关文章推荐
- IOS开发基础之──NSLog 输出格式详解
- ios输出格式 NSLog
- Xcode8打印一堆日志、iOS10真机NSLog输出无效解决办法
- 解决CodeSmith代码模版输出文件的编码格式为有bom的UTF-8的问题
- iOS中NSLog输出格式大全
- ios中NSLog输出格式大全
- 解决iOS 打印出来的汉字为UTF8 格式
- iOS中NSLog输出格式
- iOS中NSLog输出格式大全
- iOS数据类型简介及NSLog打印输出
- iOS开发基础:NSLog输出格式详解
- ios开发之常用的NSLOG日志打印格式
- IOS开发基础之──NSLog 输出格式详解
- Xcode8打印一堆日志、iOS10真机NSLog输出无效解决办法
- IOS开发基础之──NSLog 输出格式详解
- ios NSLog输出格式控制
- iOS中NSLog输出格式大全
- IOS开发教程--NSLog输出格式控制
- 本文的内容是总结了一下iOS开发中NSLog输出格式大全
- 完美解决Xcode8.0之后版本NSLog打印输出不全