LLDB display of NSDate is inconsistent?

筅森魡賤 提交于 2019-12-04 18:42:45

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!