why doesn't this work in XCode debug window "po [myNsDateComponent weekday]"
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.开发者_如何学JAVA
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
精彩评论