iOS Realm对象(通过引用或重复对象) [英] iOS Realm object by reference or duplicate objects

查看:167
本文介绍了iOS Realm对象(通过引用或重复对象)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用领域,对此我不确定.

I am using realm and I am not sure about this.

在Post中,我有两个选择.一种是保存整个所有者对象,另一种是仅保存用户对象ID.如果我保存整个对象,是否是按引用的对象?我不想增加数据库大小.

I have two option to do in Post. One is to save entire owner object and another is to save only user object ID. If I save entire object, is it object by reference? I don't want to increase database size.

我要存储整个对象的原因是它易于访问.就像Post.User.email.我不需要查询.我虽然阅读了领域. https://realm.io/docs/objc/latest/

The reason why I want to store entire object is that it is easy to access. It is like Post.User.email. I don't need to query. I read through realm though. https://realm.io/docs/objc/latest/

先谢谢了.

推荐答案

无需输入ID.在Realm中,当您添加另一个RealmObject类型的属性时,该属性将存储引用,而不是整个对象.因此,它不会在磁盘上占用比您期望的更多的空间.

No need to go by ID. In Realm, when you add a property of another RealmObject type, that will store the reference, not the entire object. So it will not take more space on disk than what you are expecting.

我不确定您的图表是否反映了您的实际类型,但是请注意,在使用集合时,您希望它们的类型为RealmList<>而不是Array<>(我假设您是在编写C#时所引用的, Xamarin文档).

I am not sure if your diagram reflects your actual types, but note that when using collections, you want them to be of type RealmList<>, not Array<> (I am assuming you are writing C# as you referred to the Xamarin docs).

这篇关于iOS Realm对象(通过引用或重复对象)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆