Realm. If, by now, you haven’t heard of it, it’s time to click on that link and come back when you’ve mastered the basics.
Realm and CoreData solve similar problems using different approaches. While Realm also hides most of the complexity that comes with persisting object graphs, it does so on a different level of granularity. Mostly this approach feels more natural. One of those areas is the behaviour in situations where you update your objects from more than one realm. Traditionally, in Core Data, you have a number of managed object contexts and can do whatever you feel like doing in those – they won’t interfer with each other without you explicitly telling them to do so.
In the world of Realm, the default behaviour is that all Realms are automatically refreshed when another Realm manipulates the same object.
Same object does not mean “equal memory address”, but the equal object associated with a different realm.
There are situations in which this behaviour can lead to unexpected outcomes - just imagine you’re scrolling through a list of entities and halfway through another thread updates your data. This might result in a crash.
Fortunately, Realm is quite configurable and every realm has a handy property that’s called, you’ve guessed right,
autorefresh. This property is set to
true by default but you can just turn it off. If you do that, however, you might want to call
refresh() on your realm to make sure all changes that were made from other realms are synced to yours.
The official documentation has some in-depth information on that topic.