0

I've a very weird problem in RealmSwift. I've the following property in a realm object class called Device.

class Device: Object {
    ....
    dynamic var name: String = ""
    var services: List<Service> = List<Service>()
}

The issue is that when trying to fill this list and save the Device object, the service list is not saved.

While debugging I used the following to test

print(device)

Which prints the objects without any service object. and

print(device.services)

Which prints all services objects. I know it's weird, but I cannot save the object with its list object, although I can save any normal property in the device object like name property. Any idea what is happening here?

Elsammak
  • 1,102
  • 10
  • 26

1 Answers1

2

What you are describing could happen if you are directly assigning to the services property. This is not supported, and List properties should always be declared as let.

Thomas Goyne
  • 8,010
  • 32
  • 30
  • yea, I'm directly assigning to the service property. I think "append" method could work. Will try and check. – Elsammak Apr 21 '17 at 17:00