3

why doesn't this work in XCode debug window "po [myNsDateComponent weekday]" ?

Specific example:

(gdb) po weEndDayTime
<NSDateComponents: 0x4f241d0>

(gdb) po [weEndDayTime weekday]
0x2 does not appear to point to a valid object.
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Greg
  • 34,042
  • 79
  • 253
  • 454

1 Answers1

7

The -weekday method of NSDateComponents returns an int. But po doesn't work with primitive value types, only pointer types.

In this case, it's converting the integer output of that method, 0x2, to a pointer, and looking for an object with the pointer address of 0x2. It can't find anything, so it gives that message.

Use p instead, with the appropriate typecast if necessary:

(gdb) p (int) [weEndDayTime weekday]
$1 = 2
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
  • actually when I try this I get - "Unable to call function "objc_msgSend" at 0x11ed08c: no return type information available. To call this function anyway, you can cast the return type explicitly (e.g. 'print (float) fabs (3.0)')" ? – Greg May 09 '11 at 02:40
  • Then try casting it as it tells you? – BoltClock May 09 '11 at 02:43