Saving Array to Realm in Swift?

前端 未结 2 1655
无人及你
无人及你 2021-01-11 11:47

Is it possible to save an array of objects to Realm? Anytime I make a change to the array it should be saved to Realm.

My current solution is to save ob

2条回答
  •  忘掉有多难
    2021-01-11 12:27

    To save lists of objects you have to use a Realm List, not a Swift Array.

    let objects = List()
    

    Then, you can add elements:

    objects.append(object1)
    

    Take a look at to many relationships and Collections sections of the official docs.

提交回复
热议问题