Can’t find momd file: Core Data problems

Here are a few recommendations:

  • The code you posted to get the .mom(d) file is not exactly the recommended way. Use mergedModelFromBundles instead, as in

    self.managedObjectContent= [NSManagedObjectModel mergedModelFromBundles:nil];
    

    It takes care of getting the path, choosing/merging the correct mom or momd, and initializing of the MOC all by one step. You should use this. But note that you need to clean the build process once in a while, as discussed in this SO question/answer.

  • This shows that, although crawling through StackOverflow is often good, that’s not the best approach when you deal with a big framework like CoreData.

    Honestly, take a day and read the documentation from the start to the end. You might want to google bits of code and to start coding immediately, but reading through the documentation definitely saves the development time considerably in the long run.

    Also, Marcus Zarra’s CoreData book (see here) helped me a lot. It might look expensive, but it was totally worth while.

  • On a different topic, I don’t think it a good strategy to put the pre-cooked sqlite file into the simulator’s directory (inside ~/Library/Application Support/iPhone Simulator/) even for development purpose… because it doesn’t work on the real device. If you need to do so, put the sqlite file as a resource of the app, and copy it at the launch time to either Documents or Caches, and use that afterwards.

Leave a Comment