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

Total Post:23

Posted on    September-29-2015 1:51 AM

 iPhone iPhone  Ios  Objective C 

 1 Reply(s)
 788  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:214

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