It’s hard to say whether this is correct or not because you didn’t post a link to the tutorial you’re following. However, I replicated something like this myself and the behaviour you’re seeing isn’t too off the wall. Consider this program:
class Sight {
var name: String
init(name: String) {
self.name = name
}
}
func main() {
let sight = Sight(name: "Hillhead Library")
print(sight)
}
main()
If I set the breakpoint on the print(…)
line, the debugger shows very little detail for the sight
value. To see the name
property I have to click the disclosure chevron next to it:
And if I do a po
I get nothing useful there either:
(lldb) po sight
<Sight: 0x600000205300>
To fix that, I implemented the CustomDebugStringConvertible
protocol:
extension Sight: CustomDebugStringConvertible {
var debugDescription: String {
"Sight(name:\(self.name))"
}
}
With that, I get a useful result from po
:
(lldb) po sight
Sight(name:Hillhead Library)
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"