IN OBJECTIVE-C HOW TO DUMP DATA STORED OBJ-C OBJECT

zack mathews

Total Post:23

Points:161
Posted by  zack mathews
 808  View(s)
Ratings:
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. Tarun Kumar

    Post:214

    Points:1642
    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.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!