Re: Core data in private framework.

2008-09-19 Thread Chris Hanson

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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Core data in private framework.

2008-09-18 Thread Scott Andrew
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.


Scott Andrew
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]