In Objective-C how to Dump Data stored obj-c object

Total Post:23

 1355  View(s)
Rate this:

In other programming languages like PHP or Perl, it is easy to dump everything that is contained in a variable. Like in PHP using var_dump() or print_r() functions and Perl has the Data::Dumper CPAN class, etc.

So, I want something like that in Objective-C, in few cases it would be very convenient to able to dump everything like that, instead of using gdb to inspect each variable.

  1. Post:214

    Re: In Objective-C how to Dump Data stored obj-c object

    I will use to debug NSArray contents using the code:

    NSEnumerator *enum = [arrObj objectEnumerator];
    id obj;    
    while ( obj = [enum nextObject] ) {
       NSLog(@"%@", obj);

    The code above enumerate all objects in the NSArray arrObj, so we can iterate through and also can print every object.
    I hope this code will be helpful for you.


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.