核心数据食谱问题

发布于 2024-10-29 01:46:11 字数 211 浏览 0 评论 0原文

这只是我对苹果核心数据“Recipes”项目的一个简单问题,所以我不需要详细的答案。当您编辑菜谱时,您还可以编辑类型。当按下类型单元格时,它会向用户呈现一个由多种类型填充的表格视图。这些类型究竟是如何创建的?我似乎无法在项目代码或 .xcdatamodel 中找到解释(我到处检查并搜索它)另外,为什么“RecipeType”必须是它自己的实体?为什么它不能只是“Recipe”实体的一部分?这有什么关系吗?

This is just a quick question I have about Apple's core data "Recipes" project, so I don't need elaborate answers. When you edit a recipe you can also edit the type. When the type cell is pressed it presents the user with a table view populated by multiple types. How exactly were those types created? I can't seem to find an explanation in the project code or in the .xcdatamodel (I've checked everywhere, and searched it) Also, why does "RecipeType" have to be it's own entity? Why can't it just be part of the "Recipe" entity? Does that have anything do with it?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

美人骨 2024-11-05 01:46:11

在这种情况下,RecipeType 不一定必须是它自己的类型,但这是常见的做法。使用这样的关联有很多好处。假设您想为每种类型添加更多元数据,您可以将其添加到 RecipeType 中,而不是在整个食谱中复制一堆数据。

看来这些配方类型已经插入到 SQLite 数据库 Recipes.sqlite 中。他们似乎没有使用项目中的任何代码来填充此数据库。这很可能是使用终端或其他一些 GUI SQLite 编辑器完成的。

In this case RecipeType doesn't necessarily have to be its own type, but it is common practice. Using an association like this has many benefits. Say if you wanted to add more metadata per type, you could add it to the RecipeType instead of duplicating a bunch of data throughout your recipes.

It appears that these recipe types are already inserted into the SQLite database Recipes.sqlite. It doesn't appear that they used any of the code in the project to populate this database. It was most likely done using Terminal or some other GUI SQLite editor.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文