Swift Realm: After writing transaction reference set to nil

删除回忆录丶 提交于 2019-12-01 13:43:54

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

Can you try removing the line

realm.add(newFamily)

from your write block?

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!