You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vargroupsObserver= realm.objects(Group.self).observe{(changes:RealmCollectionChange)in
switch changes {case.update(let groups,let deletions,let insertions,let modifications):letmodifiedGroups= modifications.map{groups[$0]}
for modifiedGroup in modifiedGroups {// Here I would like to get the childrenIds value BEFORE the change// modifiedGroup.childrenIds.oldValue }// ...}}
I would like to access the old: "childrenIds" value in order to compare with the newValue on a value changed.
I know that the RealmCollection observer doesn't have a: oldValue property, so I tried to define a: a Key Path Change Listener but since I need it for every Group object that is in memory - i tried to setup the Listener on the Group's init method but then I get the following crash exception: *** Terminating app due to uncaught exception 'RLMException', reason: 'Only objects which are managed by a Realm support change notifications'
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello, I have a: "Group" model which contains: ObjectId List of children:
I have defined a RealmCollection observer:
I would like to access the old: "childrenIds" value in order to compare with the newValue on a value changed.
I know that the RealmCollection observer doesn't have a: oldValue property, so I tried to define a: a Key Path Change Listener but since I need it for every Group object that is in memory - i tried to setup the Listener on the Group's init method but then I get the following crash exception:
*** Terminating app due to uncaught exception 'RLMException', reason: 'Only objects which are managed by a Realm support change notifications'
Any ideas how to approach this problem?
Beta Was this translation helpful? Give feedback.
All reactions