Attempting to use the Realm Object Server tutorial

I created an Amazon Web Services EC2 instance and deploy one of the AMIs with the Realm object server, as its documentation explains: https://realm.io/docs/realm-object-server/#install-realm-object-server

After installing and creating my administrator, I completed the iOS tutorial: https://realm.io/docs/tutorials/realmtasks/ , only up to level 7, it’s enough to create but when I add a new task to the application, nothing happens. Debugging, I notice that the following try clause fails:

let items = self.items
try! items.realm?.write {
                items.insert(Task(value: ["text": text]), at: items.filter("completed = false").count)
            }

The collection of elements seems to be properly initialized:

enter image description here

In the ROS control panel, you can see the database specified in Xcode: realm control panel from the synchronization path to the databases with the database

, " " , ? , ? , - ?

+4
3

, , , , realm init , , .

, -, , TaskList self.realm

            // Show initial tasks
            func updateList() {
                if self.realm.objects(TaskList.self).count == 0 {

                    let list = TaskList()
                    list.id = "000001"
                    list.text = "lista de prueba"

                    // Add to the Realm inside a transaction
                    try! self.realm.write {
                        self.realm.add(list)
                    }

                }
                if self.items.realm == nil, let list = self.realm.objects(TaskList.self).first {
                    self.items = list.items
                }
                self.tableView.reloadData()
            }

, , self.realm.objects(TaskList.self).count == 0 {, init realm.

+4

, Mac . , . Mac , , items Realm.

:

-, Get Started, Realm Mobile Platform RealmTasks MacOS.

ROS AWS. ROS .

, Mac AWS, . iOS.

+3

, , . , .

, Realm, . , Realm - , .

So, back to your code:

try! items.realm?.write { … }

I assume that the problem is that the collection is not yet attached to the kingdom, therefore it items.realm?is evaluated as null. In this case, the write transaction will not be completed. You can solve this problem by making sure to first add itemsto Realm or record directly in the synchronized realm.

0
source

Source: https://habr.com/ru/post/1667736/


All Articles