I am puzzled by the differences underlined in red below:
How come this very same NSDate object is displayed in BST in the debug pane, but in GMT in the LLDB terminal when asked to '"Print description of "date"' ?
This is with Xcode 4.6.1
I am puzzled by the differences underlined in red below:
How come this very same NSDate object is displayed in BST in the debug pane, but in GMT in the LLDB terminal when asked to '"Print description of "date"' ?
This is with Xcode 4.6.1
An NSDate
represents a specific moment in time, without any consideration of what human beings call that moment. If you look at NSDate
, you'll notice that there aren't even hour
, minute
, or second
properties, let alone a timeZone
property. The time zone is a feature of the NSCalendar
used to interpret that NSDate
for display. (You may be more familiar with NSDateFormatter
; it internally uses an NSCalendar
to interpret the date.)
In this case, Xcode happens to configure the calendar for the variables panel a little differently from how LLDB configures the one for the debug console. I'd have to guess that the debug console is calling -description
, which always uses UTC, while the variables panel is using a date formatter that respects the current time zone. (Your Mac is configured to use BST, right? If not, that's an odd choice...)
Brent's reply is fine - but I wanted to address one detail specifically. lldb has built in type formatters for many common types including NSDate
. If you did p date
in the debugger console, you would get the same output as you see in the Locals window. When you right-click/control-clicked on the variable and did 'Print description', it is equivalent to writing po date
in the console -- as Brent says, it calls the -description
method.
This isn't a console vrs. Locals window difference, or an Xcode vrs. lldb difference. One access method is using lldb's built in data formatters and one is calling -description
.