Beautify NSLog of NSArray & NSDictionary Beautify NSLog of NSArray & NSDictionary ios ios

Beautify NSLog of NSArray & NSDictionary


Hmm. Simple

NSLog( @"%@", dictionaryYouWantToPrint );

outputs following result for me:

{    id = 1;    matchCount = 0;    matchPattern = abcdef;    number = "123456";    sessionID = 5;    status = Unknown;    timerStart = 1367229348;}


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


Maybe you can use block after iOS5, like

[anArray enumerateObjectsUsingBlock:^(id object, NSUInteger index, BOOL *stop) {    NSLog (@"object->%@",object);}];[aDictionary enumerateKeysAndObjectsUsingBlock:^(id key, id object, BOOL *stop){    NSLog(@"key->%@, value-> %@",key,object);}];