Reputation: 7067
The app crashes when it runs. It works fine in the simulator but not on an iPhone.
Aug 9 14:20:44 unknown Mobile[1152] : * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'executeFetchRequest:error: A fetch request must have an entity.'
What should I be looking for to determine why it breaks on the device but works on the simulator?
One place I read that the name might be incorrect in the AppDelegate because its case-insensivity in the simulator but it looks ok to me.
Upvotes: 4
Views: 5724
Reputation: 2408
Check whether you are calling exactly same names of entity that you have defined in model like MyEntity
or MyAttributes
Upvotes: 0
Reputation: 13458
"A fetch request must have an entity"
You must be using Core Data, and when you're calling [fetchRequest setEntity:entity]
, perhaps entity is nil? Run in a debugger to trace back why.
You should delete your app from Simulator to ensure you're starting fresh and to force Core Data to build your persistent store. This might explain why you're seeing different behavior on device vs. in simulator
Upvotes: 2
Reputation: 147
Make sure any time you are referring to your entity, you have the correct name. For example, my entity's name was "Workout" and I accidentally had "Workouts" like below.
NSEntityDescription *workouts = [NSEntityDescription entityForName:@"Workouts" inManagedObjectContext:_managedObjectContext];
Once I replaced it with "Workout" everything worked fine.
Upvotes: 0
Reputation: 1956
Check that CoreData model file exists and if you have changed it, delete the app from the device and run it again.
Upvotes: 1