Question

I'm starting the process of converting an app to Core Data. I built the data model and, at first, got Xcode to successfully create NSManagedObject custom classes corresponding to the entities. But then I realized the entity and class names didn't have my application prefix, which I thought would dramatically increase the workload of required coding changes for the conversion to Core Data.

So I removed the references to the custom classes, renamed my entities in the data model with my prefix, reset the "class" attribute for each entity to default, and tried to create the custom classes again. I get through the wizard just as before, but now Xcode refuses to create classes for the entities, and instead creates one header-implementation pair with the application name. The .h and .m files correspond to the entity I'm classing (or the last entity in the list when I select multiple), but the names and relationships are invalid, of course, and so are useless. Can anyone explain why Xcode is doing this, and how to resolve it?

Was it helpful?

Solution

The class name for the managed objects you are creating wants to correspond to the names of the classes to be created - so I'm not sure what you mean by you reset them to default, but say your prefix is AB, and your class is Thing, then you'd want the class attribute to be ABThing. If you had already done this I may have misunderstood what you meant by returning them to default. Also, it's worth noting that if you start your application again, after changing the Core Data Model, then you have to delete the current core data model - you can use:

NSError* error = nil;
[[NSFileManager defaultManager] removeItemAtURL:<URL For your Store> error:&error];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top