Objective-c - A new application was developed for IOS and the old application was replaced with the same Bundle ID. I wanted to continue using the old coredata data, but momd could not be found.
为情所困
为情所困 2017-05-02 09:37:47
0
2
731

The customer originally had an online app, but because he was not satisfied, he asked us to develop a new one.
Now that the development is basically completed, the customer made a new request to continue the coredata data in the old App.
So I used the same Bundle ID and Bundle Name as the old APP, copied the .xcdatamodeld file to bundle请输入代码, and used the same coredata code, but the url of momd could not be obtained in managedObjectModel. After checking the contents of the bundle package,
xcdatamodeld in the old app was compiled into a bunch of momd folders, and there were a bunch of mod files in the folder. However, xcdatamodeld is not compiled in the new app. Could you please tell me why this folder does not exist?

- (NSManagedObjectModel *)managedObjectModel{
  if (_managedObjectModel != nil) {
    return _managedObjectModel;
  }
  NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"AirBoxModel" withExtension:@"momd"];
  NSLog(@"modelURL is %@", modelURL);//显示nil
  NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"AirBoxModel.sqlite"];
  NSLog(@"storeURL is %@",storeURL);
  _managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
  return _managedObjectModel;
}
为情所困
为情所困

reply all(2)
Ty80

I am also encountering such a problem now. The problem occurred after I imported something using cocoapods.
The .momd file is no longer generated in the .app file, so NSManagedObjectModel cannot be initialized. There is no way now. I can only import xcdatamodeld in build phases->compile sources. I still have the model files generated by the system. It’s useful, but if you can’t find the reason, it’s just like this

phpcn_u1582

Hahaha, it’s compiled, thank you very much

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template