I'm a little confused as to why p self.session
and po self.session
are returning different values?
Which one should I trust in my debugging? It would appear my object is nil
but then it would also appear it isn't.
Is my session.messages
nil or is it set???
Guess i should have read the docs.
Debugging
Debugging apps using Realm’s Swift API must be done through the LLDB
console.
Note that although the LLDB script installed via our Xcode Plugin
allows inspecting the contents of your Realm variables in Xcode’s UI,
this doesn’t yet work for Swift. Instead, those variables will show
incorrect data. You should instead use LLDB’s po command to inspect
the contents of data stored in a Realm.
Just so the basics are clear:
1) The lldb p
command (an alias for expr --
) evaluates the expression following the "--", and then uses memory inspection and the "data formatters" mechanism in lldb (type summaries & synthetic children, see: http://lldb.llvm.org/varformats.html for more details) to print the values of a variable.
2) The lldb po
command (an alias for expr -O --
) evaluates the given expression, and then asks the resulting object whether is has a way of describing itself (a description
or debugDescription
method in ObjC or a Mirror in Swift) and if it does, prints the string returned by that object. If it doesn't, it returns the result of #1.
Most likely, Realm was using some data formatters to present their objects via p
for ObjC and those don't exist for yet for Swift. But the object still knows how to present its debug description correctly, which is why po
works.