对于在线程之间共享的对象(通过持久化和查询),在一个线程中对被忽略的属性所做的更改在另一个线程中是否可见?
To share objects between threads or re-use them between app launches you must persist them to a Realm ... all changes you make to it will be persisted (and must be made within a write transaction). Any changes are made available to other threads that use the same Realm when the write transaction is committed.
http://realm.io/docs/cocoa/0.91.1/#writes
看起来这不适用于被忽略的属性。每个线程的对象实例都有自己的被忽略属性的副本,并且一个线程中的更改不会影响任何其他线程。是这样吗?
最佳答案
正确。当您通过重新查询从另一个线程访问 RLMObject
时,它将成为该对象的一个新实例,因此被忽略的属性不会随该实例一起携带。
话虽如此,只要您不尝试访问任何 Realm 支持的属性(否则将触发 RLMException
),您就可以传递 RLMObject
实例从一个线程到另一个线程,并且仍然继续在新线程上访问其被忽略的属性。
关于ios - 我可以在 Realm 的线程中使用被忽略的属性吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29358849/