How to dump data stored in objective-c object (NSArray or NSDictionary)

后端 未结 5 809
情深已故
情深已故 2020-12-08 00:41

Forgive me for a potentially silly question here, but in other programming languages (scripting ones like PHP or Perl) it is often easy to dump everything contained within a

5条回答
  •  臣服心动
    2020-12-08 00:45

    I usualy go with this to "debug" NSArray contents:

    NSEnumerator *arrenum = [myarray objectEnumerator];
    id cobj;     
    while ( cobj = [arrenum nextObject] ) {
       NSLog(@"%@", cobj);
    }
    

    The code will enumerate all objects in the NSArray myarray, and then iterate through and print every object.

    Hope this can be useful for someone!

提交回复
热议问题