Search code examples
iosswiftrealm

Delete object on Realm, changes order of objects


Hi I am using realm for first time and trying to delete object, delete works properly but it changes order of objects (it deletes the object, and last object in the list comes at index of deleted object). If anyone has experienced the same, please explain.


Solution

  • The objects within a Realm are not inherently ordered. If you want them to be in a specific order, you must either sort on a property that gives them that order, or store them in an RLMArray/List property, which is an ordered type.