- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
在 Realm
中,为了使对象能够持久化,它必须实现 RealmModel
或扩展 RealmObject
。使用一个比另一个有好处吗?
realm docs 中的所有内容是:
An alternative to extending the RealmObject base class is implementing the RealmModel interface and adding the @RealmClass annotation.
All methods available on RealmObject are then available through static methods.
最佳答案
考虑到 extending any non-RealmObject
classes is not possible even if you're implementing RealmModel
and adding @RealmClass
,在我看来,你只是通过强制自己使用例如 RealmObject.isValid(realmObject)
而不是你自然免费使用的 realmObject.isValid()
来获得额外的复杂性扩展 RealmObject
。
所以不,你应该坚持扩展 RealmObject
。使用 implements RealmModel
不会给您带来额外的好处。
关于java - 实现 RealmModel 而不是在 Realm 中扩展 RealmObject 有什么好处吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39519901/
我正在尝试从 BaseModel 扩展我的模型,然后实现 RealmModel。 @RealmClass public class User extend BaseModel implements R
我想使用realm-java的新功能,我可以在其中实现RealmModel接口(interface)并添加@RealmClass注释来定义表。一切正常,直到我尝试延长一些类(class)。我在编译时收
我有以下方法可以为 Realm 对象获取新 key 。我希望能够将类作为参数传递: private fun getNextKeyForObject(myClass: Class): Int {
我正在通过 Realm 实现我的单一登录用户。每次 API 调用返回一个用户对象时,我都会使用如下内容将用户保存到数据库中: realm.beginTransaction(); realm.creat
我很高兴在开发中的 Android 应用程序中使用 realm Java。我从服务器 API 接收到 JSONObject 数组,realm 通过主要 realm 实例对象上方便的 createOrU
编译错误 Realm model classes must either extend RealmObject or implement RealmModel to be considered a v
在 Realm 中,为了使对象能够持久化,它必须实现 RealmModel 或扩展 RealmObject。使用一个比另一个有好处吗? realm docs 中的所有内容是: An alternati
在我的应用程序中,我将Arraylist保存到realmlist,并且该列表正在保存到realm数据库,因此现在在运行时当我尝试使用某些搜索查询获取结果时,它会给出me java.lang.Unsup
我有一个 RecyclerView,它显示来自 Realm 数据库的项目。为此,我实现了一个基于 realm-android-adapters 的 RealmRecyclerViewAdapter它获
我是一名优秀的程序员,十分优秀!