Core data: any way to fetch multiple entities?

后端 未结 3 1366
情话喂你
情话喂你 2020-12-13 15:23

I\'m just getting started with Core Data, and as a learning exercise I\'m building an app where I need to display different types of objects in a single table view.

3条回答
  •  春和景丽
    2020-12-13 15:50

    What you're trying to do is accomplished by defining entity inheritance in your model, where "DisplayableObject" would be an abstract class defined as the parent of "Cheese" and "Pirate".

    Then you can perform a fetch request on the "DisplayableObject" entity and it will retrieve both entities' objects.

    Take a look into this article in the apple documentation: https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CoreData/KeyConcepts.html

提交回复
热议问题