I have the following code
class Family: Object {
dynamic var name = \"\"
var members = List()
}
class FamilyMember: Object {
Can you try removing the line
realm.add(newFamily)
from your write block?
It's intended behavior. Realm does not copy any data until actually access the properties. When access the properties, Realm fetch the data directly from its file. So Realm does not store any data to its ivar. Additionally, Realm object will change to another class at the moment it is persisted. That's why you cannot see any values via the debugger and nil out all value after committed.
So if you'd like to debug objects value, you can use po
command in debug console, or just use print()
method.
See also https://realm.io/docs/swift/latest/#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.
And see also: https://github.com/realm/realm-cocoa/issues/2777