• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: entity name not found when model is in private framework
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: entity name not found when model is in private framework


  • Subject: Re: entity name not found when model is in private framework
  • From: Rick Mann <email@hidden>
  • Date: Fri, 22 May 2009 17:18:34 -0700


On May 22, 2009, at 13:34:33, Adam Swift wrote:

Sure. Since the data model is now part of the framework project, when you build that framework the model should get built along with the other source files and it will be packaged up into your frameworks Resources directory:

	${BUILDDIR}/MyFramework.framework/Resources/MyModel.mom

Since it sounds like you've already got some code that's successfully loading the model when it's included in your application project, you might want to look at the initialization of the NSPersistentStoreCoordinator to see from where the model is retrieved (search for initWithManagedObjectModel:). You'll probably want to have a method that takes care of locating, loading and returning the model, if that code lives in the framework, you can use the class to lookup the framework bundle (otherwise you'll want to look up the framework bundle by it's identifier [NSBundle bundleWithIdentifier:@"com.mycompany.MyFramework"])

- (NSManagedObjectModel *)managedObjectModel {

if (managedObjectModel) return managedObjectModel;
NSBundle *frameworkBundle = [NSBundle bundleForClass:[self class]];
NSURL *modelPath = [NSURL fileURLWithPath:[frameworkBundle pathForResource:@"MyModel" ofType:@"mom"]];
managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelPath];
return managedObjectModel;
}

I think I'm understanding what you're saying. Now that my model is in a Framework, it's not automatically found and loaded by Core Data. Thing is, so far anyway, I don't have any calls to initWithManagedObjectModel: (I'm just using the Core Data document app template for the app, and the Cocoa Framework template for the Framework). So far, the model is used exclusively within the Framework, although the classes I've created for the entities will likely be exposed in the public API.


But my document object is in the app, and I think that's where the current mom is coming from, right?

Is there a place in my Framework where it gets initialized that I can make its internal MOM magically appear? Is this even the right approach?

TIA,

--
Rick

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >entity name not found when model is in private framework (From: Rick Mann <email@hidden>)
 >Re: entity name not found when model is in private framework (From: Adam Swift <email@hidden>)
 >Re: entity name not found when model is in private framework (From: Rick Mann <email@hidden>)
 >Re: entity name not found when model is in private framework (From: Adam Swift <email@hidden>)

  • Prev by Date: Re: entity name not found when model is in private framework
  • Next by Date: Save option For NSTextview.
  • Previous by thread: Re: entity name not found when model is in private framework
  • Next by thread: Re: entity name not found when model is in private framework
  • Index(es):
    • Date
    • Thread