在ViewController之间传递Realm对象 [英] Passing Realm objects between ViewControllers

查看:79
本文介绍了在ViewController之间传递Realm对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您将如何在控制器之间传递Realm对象?

How would you go about passing Realm objects between controllers?

您只传递ID,然后在新控制器中获取对象还是传递整个Realm对象?

Would you pass just the ID and then fetch the object in the new controller or just pass the whole Realm object?

推荐答案

当前的最佳做法是再次获取.如果您使用的是后台线程,则可以将主键传递给主线程,然后使用主键进行获取.由于领域如何处理对象的加载,因此在成千上万的对象中并不是什么大的性能问题

The current best practice is to just fetch again. If you are working off of a background thread, you can pass primary keys to the main thread and fetch with those. It's not that big of a performance issue in the thousand of objects due to how realm handles the loading of objects

这篇关于在ViewController之间传递Realm对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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