Inspecting the contents of an array in the Xcode debugger

11,668

If it is in scope you can just type

po newArray 

into the debugger and it will print the description.

Or if you prefer clicking things then just right click the object in the left panel pof the console and then click "Print Description of ..."

Share:
11,668
Hippocrates
Author by

Hippocrates

Updated on June 23, 2022

Comments

  • Hippocrates
    Hippocrates about 2 years

    Let's say I create an array:

    NSArray *newArray = [NSArray arrayWithObjects:@"foo", @"bar", @"sdfsf", nil];
    

    In Xcode, when I stop at a breakpoint and inspect newArray I see that it says "3 Objects", yet when I click the disclosure triangle all I see is one NSObject and there seems to be no way to see what that array contains.

    In practice I am working with an array of custom objects and it is a royal pain to see the nesting or inspect the properties of them.

    Can anyone provide some insight on a better way to use this?

  • jscs
    jscs about 12 years
    Even better, po [myArray objectAtIndex:10] will also work, as will po [[myArray objectAtIndex:10] someProperty].
  • Ryan Heitner
    Ryan Heitner about 9 years
    or po [myArray[10] someProperty]