CoreData, many-to-many relationships and NSPredicate

前端 未结 2 1203
渐次进展
渐次进展 2021-01-01 06:28

I have a CoreData datamodel that includes a many-to-many relationship. As it turns out NSPredicate does not support many-to-many relationships. From CoreData.pdf: \"You can

2条回答
  •  没有蜡笔的小新
    2021-01-01 07:04

    My understanding is that you can make any many-to-many relationship into separate one-to-many relationships by adding an intermediate entity.

    You have:
    Recipe has many Ingredients.
    Ingredient has many Recipes.

    Create a new RecipeIngredient entity such that:
    Recipe has many RecipeIngredients.
    Ingredients has many RecipeIngredients.
    A RecipeIngredient has one Recipe and one Ingredient.

提交回复
热议问题