[英]What is the best way to print a log of object with nested NSDictionary or NSArray with decoded unicode symbols?
I look for the best way to print a log of nested objects of NSArray and NSDictionary with decoded unicode symbols. 我寻找打印带有已解码unicode符号的NSArray和NSDictionary嵌套对象日志的最佳方法。
I know about description
property, but it prints unicode symbols in \\Uxxxx format. 我知道
description
属性,但是它以\\ Uxxxx格式打印unicode符号。 Also I know, that it possible to enumerate object and print it's keys separately, but it's not comfortable for big nested objects. 我也知道,可以枚举对象并单独打印其键,但是对于大型嵌套对象来说并不舒服。
For example: 例如:
NSArray *array = @[@{@"firstName":@"Марк"},@{@"lastName":@"Цекурберг"}];
NSLog(@"array %@", array);
===
array (
{
firstName = "\U041c\U0430\U0440\U043a";
},
{
lastName = "\U0426\U0435\U043a\U0443\U0440\U0431\U0435\U0440\U0433";
}
)
I want to get this: 我想得到这个:
array (
{
firstName = "Марк";
},
{
lastName = "Цукерберг";
}
)
I wrote for myself script, that takes description
string of object and replaces all \\Uxxxx (and %xx%xx) to approptiate symbols, but I think it's not the best way. 我为自己编写了脚本,该脚本采用对象的
description
字符串并替换所有\\ Uxxxx(和%xx%xx)以优化符号,但是我认为这不是最好的方法。
This is my Objective C script (NSObject extension), that do this: 这是我的Objective C脚本(NSObject扩展),它执行以下操作:
https://github.com/iOS-altima/dumpObject https://github.com/iOS-altima/dumpObject
Standard way: 标准方式:
NSArray *array = @[@{@"firstName":@"Марк%20%F0%9F%98%9C"},@{@"lastName":@"Цекурберг"}];
NSLog(@"array %@", array);
=== result ===
array (
{
firstName = "\U041c\U0430\U0440\U043a%20%F0%9F%98%9C";
},
{
lastName = "\U0426\U0435\U043a\U0443\U0440\U0431\U0435\U0440\U0433";
}
)
dumpObject way: dumpObject的方式:
NSArray *array = @[@{@"firstName":@"Марк%20%F0%9F%98%9C"},@{@"lastName":@"Цекурберг"}];
[self dumpObject:array];
=== result ===
array (
{
firstName = "Марк 😜";
},
{
lastName = "Цукерберг";
}
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.