Why this does not work in the Xcode debug window "po [myNsDateComponent weekday]"

why doesn't this work in the 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.
+3
source share
1 answer

The method -weekday NSDateComponentsreturns int. But it podoes not work with primitive value types, only with pointer types.

In this case, it converts the integer output of this method,, 0x2into a pointer and looks for the object with the address of the pointer 0x2. He cannot find anything, therefore he gives this message.

Use pinstead with appropriate typecasting if necessary:

(gdb) p (int) [weEndDayTime weekday]
$1 = 2
+7
source

All Articles