Realm crashes with RLMException: object has been deleted or invalidated

青春壹個敷衍的年華 提交于 2019-11-28 13:56:00

When the RLMProject itself is invalidated, it won't be possible to check for videoAssets.invalidated or soundtracks.invalidated, which is why your stack trace shows that an uncaught exception is being thrown in RLMGetArray.

This implies that the object has been deleted from the realm before you call setTimeLineModel. Please look for realm.deleteObject(_:) in your code to see where this might be happening.

Finally, a few general tips to make your code a little safer and simpler:

Instead of RLMRealm.defaultRealm() everywhere inside your RLMObject, you should use its realm property. This way, if you decide to change the location of your realm at some point, your code inside your RLMObject will continue to work.

Also, rather than create an extension on RLMArray to add map, you could use Swift's free map function.

map(videoAssets) { ($0 as RLMMediaAsset).getMediaAsset() }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!