美化NSArray的NSLog&的NSDictionary [英] Beautify NSLog of NSArray & NSDictionary

查看:108
本文介绍了美化NSArray的NSLog&的NSDictionary的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理深度嵌套的NSArray和NSDictionary,至少可以说它非常耗时。 [data objectatindex:0] valueForKey:@blah]等等

I'm dealing with deeply nested NSArray's and NSDictionary's and it's very time consuming to say the least. [data objectatindex:0] valueForKey:@"blah"] etc etc

有没有人知道一个漂亮的iOS类别,以递归方式记录结构,突出显示类型并显示价值?

Does anyone know of a nice iOS category to recursively log the structure, highlight the type and show the values?

可能会问多少,但你永远不会知道:)

Might be asking a bit much but you never know :)

推荐答案

也许是这样?

for (id key in dictionary) {
    NSLog(@"key: %@, value: %@ \n", key, [dictionary objectForKey:key]);
}

但我想不出有什么好办法让输出很漂亮除外副本&将其粘贴到 jsonFormatter (例如)

but i can't think of any nice way of getting the output beautiful except copy & paste it into a jsonFormatter (for example)

编辑:@Andrey Starodubtsev的XCode解决方案> 5.x以下:

EDIT: @Andrey Starodubtsev has the solution for XCode > 5.x below:

NSLog( @"%@", dictionaryYouWantToPrint );

这篇关于美化NSArray的NSLog&的NSDictionary的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆