Say I have a structure like this:
struct MyStruct: CustomStringConvertible {
let myInt: Int
let myString: String
var description: String {
return "my int is \(myInt),\nand my string is \"\(myString)\""
}
}
Printing the description from the code is working fine.
let myStruct = MyStruct(myInt: 3, myString: "hello")
print(myStruct)
The result is
my int is 3,
and my string is "hello"
Problems arise when I want to print a description myStructfrom the debugger. po myStructleads to
▿ my int is 3,
and my string is "hello"
- myInt : 3
- myString : "hello"
Explicitly printing out its description also does not help, because it po myStruct.descriptionleads to
"my int is 3,\nand my string is \"hello\""
I thought this could be due to CustomDebugStringConvertible, so I added this code:
extension MyStruct: CustomDebugStringConvertible {
var debugDescription: String {
return description
}
}
Unfortunately, this in no way alters any results.
Is there any way to have
my int is 3,
and my string is "hello"
printed from the command line during debugging?