0

I have different model of coredata in my project. Certainly I added xcdatamodel file in my project, it crash because in my Appdelegate I have:

- (NSManagedObjectModel *)managedObjectModel

    {
        if (managedObjectModel != nil) {
            return managedObjectModel;
        }



        NSString *path = [[NSBundle mainBundle] pathForResource:@"Model" ofType:@"momd"];


         NSURL *momURL = [NSURL fileURLWithPath:path];
       managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:momURL];



        return managedObjectModel;
    }

and in order to make it work it should be:

- (NSManagedObjectModel *)managedObjectModel
{
    if (managedObjectModel != nil) {
        return managedObjectModel;
    }

      managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:nil] ; 


    return managedObjectModel;
}

I there anyway to have both methods ?

Steven
  • 762
  • 1
  • 10
  • 27
  • Why do you need both? The second should load (and merge) any models in the main bundle, including the model you specify in the first. – pbasdf Nov 28 '17 at 16:18
  • Thanks @pbasdf, I wasn't sure about that if the second should load (and merge) any models in the main bundle, including the model i specify in the first. – Steven Nov 29 '17 at 08:26

0 Answers0