Beautify NSLog of NSArray & NSDictionary

前端 未结 4 1382
执笔经年
执笔经年 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 03:08

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

提交回复
热议问题