核心数据食谱问题
这只是我对苹果核心数据“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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下,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 theRecipeType
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.