reason: 'An NSManagedObject of class 'NSManagedObject' must have a valid NSEntityDescription?

1.6k Views Asked by At

I am getting error in core data x code8.3, Data base is added DB.

Error is.....

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'An NSManagedObject of class 'NSManagedObject' must have a valid NSEntityDescription

App Name : GPSLocation

Database Name : GPSLocationDataBase (Data base created middle of the project)

Entity Name : GPSLocationEntity

1

There are 1 best solutions below

4
On

Are you created the NSPersistentContainer with the GPSLocationDataBase name? Like

let container = NSPersistentContainer(name: "GPSLocationDataBase")

? A persistentContainer with different name can cause this issue.

In Obj-C:

NSPersistentContainer *container = [[NSPersistentContainer alloc] initWithName: @"GPSLocationDataBase"];