Beautify NSLog of NSArray & NSDictionary

前端 未结 4 1393
执笔经年
执笔经年 2021-01-31 02:32

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

4条回答
  •  攒了一身酷
    2021-01-31 02:49

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

提交回复
热议问题