简体   繁体   English

用嵌套的NSDictionary或带有解码的unicode符号的NSArray打印对象日志的最佳方法是什么?

[英]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.

相关问题 许多 NSDictionary 的 NSArray。 为给定键找到具有必要值的 NSDictionary 的最佳方法是什么? - NSArray of many NSDictionary. What is the best way to find a NSDictionary with necessary value for given key? 排序NSDictionary对象的NSArray的最佳方法? - Best way to sort an NSArray of NSDictionary objects? RestKit与NSDictionary和NSArray对象的映射 - RestKit mapping with NSDictionary and NSArray object 如何在 NSArray 中的 NSDictionary 中引用 object - How to refer to an object in a NSDictionary that is in a NSArray 嵌套的NSDictionary和NSArray,AFNetworking无法正常工作 - Nested NSDictionary & NSArray with AFNetworking not working properly 在xCode中解析嵌套的NSDictionary和NSArray数据 - Parsing Nested NSDictionary and NSArray Data in xCode 替换嵌套NSDictionary中的值重复NSArray中的值 - Replacing values in nested NSDictionary duplicates values in NSArray 将所有对象属性放入NSDictionary或NSArray中 - Put all object properties into an NSDictionary or NSArray 按月将NSArray与NSDate对象分类到NSDictionary中 - Sort NSArray with NSDate object into NSDictionary by month 将自定义对象序列化为NSDictionary或NSArray以使用NSJSONSerialization - Serializing a custom object into NSDictionary or NSArray to use NSJSONSerialization
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM