2016-09-15 91 views

回答

2

考慮到extending any non-RealmObject classes is not possible even if you're implementing RealmModel and adding @RealmClass,在我看來,你只是強迫自己使用例如RealmObject.isValid(realmObject),而不是realmObject.isValid()您得到自然的免費使用extends RealmObject獲得額外的複雜性。

所以不,你應該堅持延伸RealmObject。使用implements RealmModel不會帶來額外的好處。

+2

目前'RealmModel'的唯一好處是你可以擁有自己定製的'isValid()'。如果你擴展'RealmObject',你不能在你自己的類中使用這種方法。 –

+0

我想'isManaged()'和'isLoaded()'(和'deleteFromRealm()')也是這樣。 – EpicPandaForce

+0

是的,它適用於'RealmObject'上的所有方法,因爲我們把它們都做成了final。 –

相關問題