I have tried a lot of options, but can\'t find the solution for this problem. I created a Core Data file and named the entity Account, Created an string attribute called use
- (NSManagedObjectContext *)managedObjectContext
{
if (managedObjectContext != nil) return managedObjectContext;
NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
if (coordinator != nil) {
managedObjectContext = [[NSManagedObjectContext alloc] init];
[managedObjectContext setPersistentStoreCoordinator:coordinator];
}
return managedObjectContext;
}
persistentStoreCoordinatorcoordinator will always be nilnil from this methodTo explain the error:
+entityForName: nil is not a legal NSManagedObjectContext parameter searching for entity name 'Account'
It's not immediately obvious from reading it, but this means that nil is not a legal thing to pass for the managed object context. On first reading, it looks like you're doing entityForName:nil but that isn't the case.
To fix the problem, you will need to provide a valid persistent store coordinator. I have a small article here which explains just how little code you need to set up a core data stack, this may help you.