Group Group Group Group Group Group Group Group Group

raywenderlich.com Forums

Video Tutorial: Beginning Realm on iOS Part 3: Updating Objects

Learn how to update the contents of your stored objects and delete the ones you no longer need.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3479-beginning-realm-on-ios/lessons/4

does anyone know how he did that change of image in the button?

hey, just skip through the video to time 4:40 - there you will see I’m setting the selected state of the button. I have already set the un-checked and checked images in Interface Builder for that button for the normal and selected states of the button and I just toggle the “selected” property to switch the states.

1 Like

Nice intro. But even if it’s a demo shouldn’t you not recommend to update a model from a view!?! It seem pretty hardcore.

Time is very restrained in this web episodes, I fit the maximum I can :slight_smile:

So in TaskCell and CreateNewTask, we are calling let realm = try! Realm()

Is this creating a new Realm instance each time? If so how is results maintained? Or does an app only have one instance. It seems that calling Realm() returns the default realm each time unless we specify some other configuration. Is this correct?
This is a bit confusing, thanks for the help and the tutorial.

hi andypf, the code you refer to is not creating new Realm instances. You create a new reference to your Realm file on the current thread - this is part of Realm’s thread safe strategy. Each time you call Realm() on the same thread you will get back the same object, if you do that on antoher thread you will receive another object, which points to the same file on disk. Using multiple realm files is covered in the “Intermedaite Realm on iOS” video series