核心数据中的根实体

发布于 2025-01-31 18:49:24 字数 268 浏览 2 评论 0原文

我基本上试图使用核心数据重新创建文件夹系统。我有一个拥有许多相同实体(文件夹)的实体(文件夹)。在初始化核心数据堆栈的同时,我可以显示所有文件夹,但是我不确定如何处理始终持久的核心数据实体,该核心数据实体将是所有其他文件夹的“根”文件夹。 (将其视为Finder中的“ Macintosh HD”)。

我正在考虑创建一个没有删除规则的单独的根实体,并将其算作“根”文件夹,然后将文件夹添加到它(创建一个新文件夹时,我可以使用核心数据关系提供的函数并添加到root Entity中)。这可以是一种适当的方法吗?

I'm basically trying to recreate a folder system using Core Data. I have an entity (folder) that that holds many of the same entities (folders). While initialising Core Data Stack I can display all of the folders, but I'm not sure how to approach storing an always persistent Core Data entity that will be a "root" folder for all others. (Think of it as 'Macintosh HD' in finder).

I was thinking of creating a separate root entity that has no deletion rule and count it as "root" folder and then add folders to it (while creating a new folder I could just use functions provided by Core Data relationships and add to the root entity). Could this be a proper approach?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文