Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if realm object is deleted

Tags:

ios

swift

realm

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.

like image 969
Shob-Z Avatar asked Jul 27 '16 10:07

Shob-Z


1 Answers

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

this is the Documentation of Object.isInvalidated.

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

like image 133
成璐飞 Avatar answered Oct 29 '22 15:10

成璐飞