Author Topic: How To Fix: A fetch request must have an entity  (Read 9018 times)

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
How To Fix: A fetch request must have an entity
« on: January 21, 2014, 11:05:01 AM »
If you receive the error "A fetch request must have an entity" when you are trying to retrieve entities from the datastore, it means that you are requesting a type of entity that Core Data doesn't recognize. This is usually caused by requesting an invalid entity type.

To fix this, here are a few things to check (you need to read Book 3's chapter on Core Data to understand what I'm talking about):

  • In the init method of your business controller, make sure you set the entityClassName property to the exact name of the entity class as specified in the entity data model.
  • Make sure that after generating the entity class from the entity data model, you don't change the name of the entity class. These must match exactly.

All the best!
Kevin
Author of "Learn to Code in Swift": https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
« Last Edit: July 17, 2015, 04:11:11 PM by kjmcneish »