Home > DeveloperSection > Forums > In Objective-C how to Dump Data stored obj-c object
zack mathews
zack mathews

Total Post:23

Points:161
Posted on    September-29-2015 1:51 AM

 iPhone iPhone  Ios  Objective C 
Ratings:


 1 Reply(s)
 500  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.



Tarun Kumar

Total Post:213

Points:1635
Posted on    September-29-2015 11:38 PM

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.


Don't want to miss updates? Please click the below button!

Follow MindStick