iOSDevil iOSDevil - 1 year ago 101
iOS Question

Beautify NSLog of NSArray & NSDictionary

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

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 :)

Answer Source

Maybe like this?

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

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

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

NSLog( @"%@", dictionaryYouWantToPrint );
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download