Alex Rivera | Logout

iPhone - Add Core Data To existing Project?

Asked 2010-10-11T18:12:24.793
19

I am trying to add core data functionality to an existing project. I added a data model file named "myProj.xcdatamodel"

My code crashes in the following when getting the managedObjectModel What is the "momd" file? where can i get it or how can i create it? When i read the path it returns null and crashes the app.

NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"myProj" ofType:@"momd"];
NSURL *modelURL = [NSURL fileURLWithPath:modelPath];
Edit
Report

1 Answer

5

the "mom" or "momd" file is the compiled version of the .xcdatamodel file. Perhaps you didn't add the .xcdatamodel file to the target so it isn't getting compiled? Do Get Info on it and make sure it's building for your target.

Also check out the CoreDataBooks sample code.

answered 2010-10-11T18:58:41.780

Your Answer