Re: Core data in private framework.
Re: Core data in private framework.
- Subject: Re: Core data in private framework.
- From: Chris Hanson <email@hidden>
- Date: Fri, 19 Sep 2008 01:47:36 -0700
On Sep 18, 2008, at 8:41 PM, Scott Andrew wrote:
I have a question. We are designing a private frame work to wrap our
data handling. The framework is using Core Data with an SQL back
end. However we get errors when loading data if the model file is
not included in the application and is just in the framework. I
looked through the docs and couldn't find any help. Are there any
tricks to having the data model file (.mom) exist in the private
framework and not in the application's resources? We would like the
data class to be used across applications by just including the
framework.
There's nothing special about where a data model is located.
Core Data will use all of the models in your main bundle's Resources
directory if you use +[NSManagedObjectModel mergedModelFromBundles:]
and pass it nil. That's a convenience, you don't have to use that API.
You can just construct a URL containing a file path to the model, e.g.
using -[NSBundle pathForResource:ofType:] (on your framework's bundle)
and +[NSURL fileURLWithPath:isDirectory:], and use -
[NSManagedObjectModel initWithContentsOfURL:] to initialize a model
that you +alloc.
-- Chris
_______________________________________________
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