When I use print()
on a dictionary in Swift, it comes out nice and pretty in the console, with a key and a value.
object = Optional({
customerId = 111;
transactionId = 333;
extraId = 444;
})
When I run po
on that same dictionary, it spits out this nonsense dump which is incredibly hard to read.
▿ Optional<Any>
▿ some : 3 elements
▿ 0 : 2 elements
▿ .0 : transactionId
- .1 : 333
▿ 1 : 2 elements
▿ .0 : customerId
- .1 : 111
▿ 2 : 2 elements
▿ .0 : extraId
- .1 : 444
Using just p
is even worse
(Any?) $R8 = some {
payload_data_0 = 0x0000000170e679c0 {
Swift._SwiftNativeNSDictionary = {}
_heapBufferBridged_DoNotUse = 0x0000000170e679d0 {}
nativeStorage = {
buffer = 0x00000001703e4300 {
Swift.ManagedBuffer = {}
}
initializedEntries = (values = 0x00000001703e4328, bitCount = 4)
keys = 0x00000001703e4330
values = 0x00000001703e4390
}
}
payload_data_1 = 0x0000000000000000
payload_data_2 = 0x0000000000000000
instance_type = 0x0000000105ffc3f8
}
What can I do in the console to see my variables in a way that I can actually read them without having to sift through all this nonsense?
PS - In this case I am printing an Optional<Any>
object that happens to be a dictionary, but it's the same with a non-optional Dictionary.