"Cannot load NSManagedObjectModel. nil is an illegal URL parameter"
I had the same problem but for me the modelURL was correctly set. The problem was that my *.xcdatamodeld file was not in the Copy bundle ressources anymore. I don't know why it disappear but to add it again fix the problem.
Here is how to fix it : You project > Build Phases > Copy Bundle ressources > "+" button and select you xcdatamodeld file
The problem is this line:
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"FoodPin" withExtension:@"momd"];
modelURL
is nil
meaning that the system couldn't find the resource FoodPin.momd
.
Make sure you have a Core Data model in your project named FoodPin
. It will appear as FoodPin.xcdatamodeld
in the Project Navigator.