Shob-Z Shob-Z - 1 year ago 153
Swift Question

Check if realm object is deleted

Realm java has a function isValid() to check if a realm object is deleted/invalidated.

Is there a similar function to find it in realm swift?

I get 'Realm object has been deleted or invalidated' crash quite often, when updating those objects.

Answer Source

An object can no longer be accessed if the object has been deleted from the containing realm or if invalidate is called on the containing realm.

this is the Document of Object.invalidated

add override var isInvalidated: Bool { return super.isInvalidated } to your Object