I know this may look as a duplicate but I tried several answers and all of those did not work.
I am trying to use Core Data to store which levels are completed, but I am running in some trouble saving the data. At the moment dat a level is completed the following lines are called.
let appDelegate =
UIApplication.shared().delegate as! AppDelegate
let managedContext = appDelegate.managedObjectContext
let level = NSEntityDescription.insertNewObject(forEntityName:"SucceededLevels", into:managedContext) as NSManagedObject
person.setValue(levelName, forKey: "levels")
do {
try managedContext.save()
levelsArray.append(person)
} catch let error as NSError {
print("Could not save \(error), \(error.userInfo)")
}
But I am getting the following error
"Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an entity named 'SucceededLevels' in this model."
I have set up the entity in the .xcdatamodel.